#335: window API


su_horng (su_horng)

學校 : 劍橋大學國王學院
編號 : 1089
來源 : [111.248.42.147]
最後登入時間 :
2014-12-13 21:15:21
. Unfinished! | From: [220.137.69.200] | 發表日期 : 2008-06-15 18:38

各位好~
我這裡自己簡單包裝了一下視窗的操作,
因為MFC功能太強(用不到!)
而單純WinAPI又太麻煩。
希望誰能幫我測試一下~有問題我也好改進。

http://www.wretch.cc/blog/suhorng/29126834

//示範用法:
//main.c
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

#include "window.h"

HWND mf;

LRESULT OnLButtonUp2(WPARAM wParam,LPARAM lParam){
printf("\nOnLButtonUp2");
window_removeevent(mf,WM_MOUSEMOVE);
return 0;
}

LRESULT OnLButtonUp1(WPARAM wParam,LPARAM lParam){
printf("\nOnLButtomUp1");
window_modifyevent(mf,WM_LBUTTONUP,OnLButtonUp2);
return 0;
}

LRESULT OnMouseMove(WPARAM wParam,LPARAM lParam){
printf("\n[X=%d \tY=%d]",lParam>>16,lParam&0xFFFF);
return 0;
}

int main(){
int i;
window_init();
mf=window_create("mainframe");
window_addevent(mf,WM_MOUSEMOVE,OnMouseMove);
window_addevent(mf,WM_LBUTTONUP,OnLButtonUp1);
while((i=window_message())){
printf("<0x%X>\t",i);
}
window_destroy("mainframe",mf);
window_final();
system("PAUSE");
return 0;
}

//window.h
//視窗的建立、摧毀、訊息迴圈的簡易包裝。
.......(略),這裡排版會有問題
 
ZeroJudge Forum