Code:-
#include <windows.h>
#include <commctrl.h>
#define ID_BUTTON 10
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
switch(msg){
case WM_CREATE:{
CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "Textbox",
WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL,
10,10,200,20,
hwnd, (HMENU) ID_BUTTON, NULL, NULL
);
break;
}
case WM_COMMAND:{
break;
}
case WM_DESTROY:{
PostQuitMessage(0);
break;
}
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR nCmdLine, int nCmdShow){
HWND hwnd;
MSG msg;
WNDCLASSEX wc;
memset(&wc, 0, sizeof(wc));
wc.cbSize = sizeof(WNDCLASSEX);
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hInstance;
wc.lpszClassName = "Windowtut";
wc.lpfnWndProc = WndProc;
if(!RegisterClassEx(&wc)){
MessageBox(hwnd, "Windows Registration failed", "Error..", MB_ICONERROR);
return 0;
}
hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "Windowtut", "Window Textbox Example",
WS_VISIBLE | WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
600,
400,
NULL, NULL, NULL, NULL
);
if(hwnd == NULL){
MessageBox(hwnd, "Windows Creation failed", "Error..", MB_ICONERROR);
return 0;
}
while(GetMessage(&msg, 0, NULL, 0) > 0){
DispatchMessage(&msg);
TranslateMessage(&msg);
}
return msg.wParam;
}
Output:-
No comments:
Post a Comment