i got this sample of creating a window on borland cbuilderx
Code:
#include<windows.h>
#include<windows.h>
#ifdef _BORLANDC_
#pragma argsused
#endif
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR
lpCmdLine,int nCmdShow)
{
HWND WinForm;
MSG WinMsg;
const char *Clsname="Win32Test";
const char *Wndname="GS Application";
HINSTANCE WinIns;
WinIns=hInstance;
WNDCLASSEX WndRegist;
WndRegist.cbSize = sizeof(WNDCLASSEX);
WndRegist.style = CS_HREDRAW | CS_VREDRAW;
WndRegist.lpfnWndProc = WndProcedure;
WndRegist.cbClsExtra = 0;
WndRegist.cbWndExtra = 0;
WndRegist.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndRegist.hCursor = LoadCursor(NULL, IDC_ARROW);
WndRegist.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndRegist.lpszMenuName = NULL;
WndRegist.lpszClassName = Clsname;
WndRegist.hInstance = WinIns;
WndRegist.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&WndRegist);
WinForm=CreateWindow(Clsname,Wndname,WS_OVERLAPPEDWINDOW,100,100,500,300,NULL,NULL,WinIns,NULL);
if(WinForm)
{MessageBox(NULL,"Window successful created.","SystemMessage",MB_OK|MB_ICONINFORMATION);}
else
{MessageBox(NULL,"Error: Something happend,something bad ...","SystemMessage",MB_OK|MB_ICONWARNING);return 0;}
ShowWindow(WinForm,SW_SHOWNORMAL);
UpdateWindow(WinForm);
while( GetMessage(&WinMsg, NULL, 0, 0) )
{
TranslateMessage(&WinMsg);
DispatchMessage(&WinMsg);
}
return Msg.wParam;
}
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_CREATE:
return 0;
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
and i have these question :
1.what is this for?
Code:
#ifdef _BORLANDC_
#pragma argsused
#endif
2.what is the meaning of this 'classname'?
Code:
const char *Clsname="Win32Test";
3.what do these codes do? set some basic attribute of the window?
Code:
WNDCLASSEX WndRegist;
WndRegist.cbSize = sizeof(WNDCLASSEX);
WndRegist.style = CS_HREDRAW | CS_VREDRAW;
WndRegist.lpfnWndProc = WndProcedure;
WndRegist.cbClsExtra = 0;
WndRegist.cbWndExtra = 0;
WndRegist.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndRegist.hCursor = LoadCursor(NULL, IDC_ARROW);
WndRegist.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndRegist.lpszMenuName = NULL;
WndRegist.lpszClassName = Clsname;
WndRegist.hInstance = WinIns;
WndRegist.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&WndRegist);
4.does this function receive all the messages that sent by system? please tell me more details.
Code:
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_CREATE:
return 0;
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
any help would be great appreciated ....