글

[Win32 API] GetMessage Function()

Retrieves a message from (only) the calling thread's message queue. Syntax BOOL WINAPI GetMessage( __out     LPMSG lpMsg, __in_opt  HWND hWnd, __in      UINT wMsgFilterMin, __in      UINT wMsgFilterMax ); Parameters lpMsg : A pointer to an MSG structure that recives message information from the thread's message queue. hWind : A handle to the window whose message are to be retrieved. The Window must belong to the current thread. If hWnd is NULL, GetMessage retrieves message for any window that belong to the current thread, and any messages on the current thread's message whose hwnd value is NULL. Therefore if hWnd is NULL, both window massages and thread messages are processed. wMsgFilterMin : The integer value of the lowest message value to be retrieved. ex) Use WM_KEYFIRST(0x0100) to specify the first keyboard message or WM_MOUSEFIRST(0x0200) to specify the first mouse me...

[Win32 API] ShowWindow Function

Set the specified windows's show state. Syntax BOOL WINAPI ShowWindow( __in  HWND hWnd, __in  int nCmdShow ); Parameter hWin : A handle to the window. nCmdShow : Controls how the window is to be shown. This parameter can be use one of the following values. Value Meaning SW_FORCEMINIMIZE 11 Minimizes a window, even if the thread that owns the window is not responding. This flag should only be used when minimizing windows from a different thread. SW_HIDE 0 Hides the window and activates another window. SW_MAXIMIZE 3 Maximizes the specified window. SW_MINIMIZE 6 Minimizes the specified window and activates the next top-level window in the Z order. SW_RESTORE 9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window. SW_SHOW 5 Activates the window and displays it in its current siz...

[Win 32 API] GetStockObject Function

The GetStockObject function retrieves a handle to one of the stock pens,brush,fonts, or palettes. Syntax HGDIOBJ GetStockObject( __in  int fnObject ); Parameters The type of stock object. This parameter can be one of the following values. Value Meaning BLACK_BRUSH Black brush. DKGRAY_BRUSH Dark gray brush. DC_BRUSH Solid color brush. The default color is white. The color can be changed by using the  SetDCBrushColor  function. For more information, see the Remarks section. GRAY_BRUSH Gray brush. HOLLOW_BRUSH Hollow brush (equivalent to NULL_BRUSH). LTGRAY_BRUSH Light gray brush. NULL_BRUSH Null brush (equivalent to HOLLOW_BRUSH). WHITE_BRUSH White brush. BLACK_PEN Black pen. DC_PEN Solid pen color. The default color is white. The color can be changed by using the  SetDCPenColor  function. For more information, see the Remarks section. NULL_PEN NULL pen. The null pen draws nothing. WHITE_PEN White pen. ANSI_FIXE...

[Win32 API] LoadCursor Fuction

Load the cursor resource named by lpszResourceName or                                                specified by nIDResource from the current executable file. Syntax HCURSOR WINAPI LoadCursor( __in_opt HINSTANCE hInstance, __in LPCTSTR lpCursorName ); Parameter lpszResourceName : Point to a nul-terminated string that contains the name of the cursor resource. You can use a Cstring for this argument. nIDResource : ID of the cursor resource. For a list of resources, see LoadCursor in the Windows SDK. Value Meaning IDC_APPSTARTING Standard arrow and small hourglass IDC_ARROW Standard arrow IDC_CROSS Crosshair IDC_HAND Hand IDC_HELP Arrow and question mark IDC_IBEAM I-beam IDC_ICON Obsolete for applications marked version 4.0 or later. IDC_NO Slashed circle IDC_SIZE Obsolete for applications marked versi...

[Win32 API] LoadIcon Function

Load the specified icon resource. Syntax HICON WINAPI LoadIcon (   __in_opt  HINSTANCE hInstance,   __in      LPCTSTR lpIconName ) ; Parameters hInstance[optional] : A handle to an instance of the module whose executable file contains the icon to be loaded. This parameter must be NULL when a standard icon is being loaded. lpIconName : The name of the icon resource to be loaded. To use one of the predefined icons, one of the follow values. Value Meaning IDI_APPLICATION MAKEINTRESOURCE(32512) Default application icon. IDI_ASTERISK MAKEINTRESOURCE(32516) Asterisk icon. Same as IDI_INFORMATION. IDI_ERROR MAKEINTRESOURCE(32513) Hand-shaped icon. IDI_EXCLAMATION MAKEINTRESOURCE(32515) Exclamation point icon. Same as IDI_WARNING. IDI_HAND MAKEINTRESOURCE(32513) Hand-shaped icon. Same as IDI_ERROR. IDI_INFORMATION MAKEINTRESOURCE(32516) Asterisk icon. IDI_QUESTION MAKEINTRESOURCE(32514) Question mark icon. IDI_SHIELD...

[Win32 API] WINAPI - 함수호출규약

WINAPI는 함수 호출 규약으로 windef.h에 정의 되어 있다. 기본적으로 _stdcall과 _cdecl 이 있는데 , 함수를 어떤 방식으로 호출할지 결정하는지 정한다. _stdcall   함수 호출시 인자를 스택에 , 오른쪽에서 왼쪽순으로 저장한다.  func(a,b,c) 라면 스택에 c를 넣고, b를 넣고, a를 넣는다. 스택에 저장한 인자 메모리를 호출당한 쪽 함수에서 해제해 준다. _cdecl  함수 호출시 인자를 스택에 오른쪽에서 왼쪽 순으로 저장한다. _stdcall과 동일 스택에 저장한 인자 메모리를 호출한 쪽 함수 에서 해제해 준다. 윈도우즈, 베이직,파스칼등 에서는 stdcall_이 default이다.  하지만, c/c++에서는 _cdecl이 default이다.  따라서, 코딩중 Win32 API함수를 호출하는 경우에는 명시적으로 _stdcall을 써줘야한다.  예)  int   WINAPI WinMain ( HINSTANCE hInstance,                    HINSTANCE hPrevInstance,                    LPSTR lpCmdLine,                     int   nCmdShow ) ; 라고 WINAPI라고 명시하면, _stdcall로 처리된다. WINAPI를 생략하게 되면, _cdecl로 간주되어 함수를 호출하게 되면 오류가 난다. 

[Win32 API] WinMain()

Syntax _____________________________________________________________________________________ int  WINAPI WinMain ( HINSTANCE hInstance,                    HINSTANCE hPrevInstance,                    LPSTR lpCmdLine,                     int  nCmdShow ) ; _______________________________________________________________________ Parameters hInstance : Handle to the current instance of the App. hPrevInstance : Handle to the previous instance of the App.  Win32-based application, this parameter is always NULL . lpCmdLine : Point to a null-terminated string the command line for the application like c style - int main( string args[] ) nShowCmd : Specifies how the window is to be shown. This parameter can be one of the following values SW_HIDE : Hides the window. SW_SHOW : Displays the window. SW_SHOWNA : Displays a w...