도와주세요!!
글 수 15,339
2003.09.03 16:02:30 (*.104.18.54)
6713
마이크로윈도우 프로그래밍에서 버튼을 만드려고 하는데
소스는 아래와 같이 했습니다.
컴파일도 에러없이 되고 실행파일도 생겨서 실행이 되는데 버튼이 화면에 나타
나지 않네요...
make file은 강좌에 올라와있는 걸 이용했구요...
어디가 잘못 됐는지....
#include
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
HINSTANCE g_hInst;
LPSTR lpszClass = "ChildWnd";
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR
szCmdLine, int nCmdShow)
{
HWND hWnd;
MSG msg;
g_hInst = hInstance;
WNDCLASS wndclass;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = (WNDPROC)WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = 0;
wndclass.hCursor = 0;
wndclass.hbrBackground = (HBRUSH)GetStockObject(
WHITE_BRUSH );
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = lpszClass;
RegisterClass( &wndclass );
hWnd = CreateWindowEx( 0L,
lpszClass,
lpszClass,
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0,
600, 400,
NULL,
NULL,
NULL,
NULL );
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while( GetMessage( &msg, 0, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
return msg.wParam;
}
LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM
lParam )
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch( iMsg )
{
case WM_CREATE:
CreateWindow( "button",
"First Button",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
20, 20,
100, 25,
hWnd,
(HMENU)0,
g_hInst,
NULL );
CreateWindow( "button",
"Second Button",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
20, 50,
100, 25,
hWnd,
(HMENU)1,
g_hInst,
NULL );
return 0;
case WM_COMMAND:
switch( LOWORD( wParam ) )
{
case 0:
MessageBox( hWnd, strCurrent, "Button",
MB_OK );
break;
case 1:
MessageBox( hWnd, "Second Button
Clicked", "Button", MB_OK );
break;
}
return 0;
case WM_PAINT:
hdc = BeginPaint( hWnd, &ps );
GetClientRect( hWnd, &rect );
DrawText( hdc, "This is MicroWindows Test", -1,
&rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER );
EndPaint( hWnd, &ps );
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
}
return DefWindowProc( hWnd, iMsg, wParam, lParam );
}
소스는 아래와 같이 했습니다.
컴파일도 에러없이 되고 실행파일도 생겨서 실행이 되는데 버튼이 화면에 나타
나지 않네요...
make file은 강좌에 올라와있는 걸 이용했구요...
어디가 잘못 됐는지....
#include
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
HINSTANCE g_hInst;
LPSTR lpszClass = "ChildWnd";
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR
szCmdLine, int nCmdShow)
{
HWND hWnd;
MSG msg;
g_hInst = hInstance;
WNDCLASS wndclass;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = (WNDPROC)WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = 0;
wndclass.hCursor = 0;
wndclass.hbrBackground = (HBRUSH)GetStockObject(
WHITE_BRUSH );
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = lpszClass;
RegisterClass( &wndclass );
hWnd = CreateWindowEx( 0L,
lpszClass,
lpszClass,
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0,
600, 400,
NULL,
NULL,
NULL,
NULL );
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while( GetMessage( &msg, 0, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
return msg.wParam;
}
LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM
lParam )
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch( iMsg )
{
case WM_CREATE:
CreateWindow( "button",
"First Button",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
20, 20,
100, 25,
hWnd,
(HMENU)0,
g_hInst,
NULL );
CreateWindow( "button",
"Second Button",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
20, 50,
100, 25,
hWnd,
(HMENU)1,
g_hInst,
NULL );
return 0;
case WM_COMMAND:
switch( LOWORD( wParam ) )
{
case 0:
MessageBox( hWnd, strCurrent, "Button",
MB_OK );
break;
case 1:
MessageBox( hWnd, "Second Button
Clicked", "Button", MB_OK );
break;
}
return 0;
case WM_PAINT:
hdc = BeginPaint( hWnd, &ps );
GetClientRect( hWnd, &rect );
DrawText( hdc, "This is MicroWindows Test", -1,
&rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER );
EndPaint( hWnd, &ps );
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
}
return DefWindowProc( hWnd, iMsg, wParam, lParam );
}