int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
#include <windows.h>
int APIENTRY WinMain(HINSTANCE hInt, HINSTANCE hpInt, LPSTR lpLine, int nShow){
//Creating a window
CreateWindowEx(
WS_EX_CLIENTEDGE, // Window Type
WC_DIALOG, //Class Name
"MyWindow", // Window Title
WS_OVERLAPPEDWINDOW | WS_VISIBLE, // Window Proprieties
0, // x Position on the Screen
0, // y Position on the Screen
width, // window Width
height, //window Height
NULL, // Parent window
NULL,
NULL, //Hint, handle to the previous window
NULL
);
//add await time or the window will close really fast
return 0;
}
HWND myDialogWindow = CreateWindowEx( arguments);
#include <windows.h>
int APIENTRY WinMain(HINSTANCE hInt, HINSTANCE hpInt, LPSTR lpLine, int nShow){
//Creating a window
HWND hMainWindow = CreateWindowEx(
WS_EX_CLIENTEDGE, // Window Type
WC_DIALOG, //Class Name
"MyWindow", // Window Title
WS_OVERLAPPEDWINDOW | WS_VISIBLE, // Window Proprieties
0, // x Position on the Screen
0, // y Position on the Screen
width, // window Width
height, //window Height
NULL, // Parent window
NULL,
NULL, //Hint, handle to the previous window
NULL
);
//Creating a button
HWND hButton1 = CreateWindowEx(
0,
"BUTTON",// the class name, there are many classes "LABLE", EDIT", etc
"Buton",
BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
50,50,100,25,
hMainWindow ,// handle to the main parent window
NULL,NULL,NULL
);
//add await time or the window will close really fast
return 0;
}
LRESULT WINAPI proc_name(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
#include <windows.h>
//the window procedure
LRESULT WINAPI wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
//if the message is WM_CLOSE
if(message == WM_CLOSE) {
// when pressing the X on the window it will send WM_CLOSE to the window procedure
// with PostQuitMessage will exit the while loop
PostQuitMessage(0);
}
return 0;
}
//the entry point of the window
int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int){
WNDCLASSEX wc; //the window class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = wndProc; //the window procedure
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hint;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = "WindowClass"; //the class name
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
// registering the class
if(!RegisterClassEx(&wc)){
//error it can not register the class
}
// creating a window
HWND hwnd = CreateWindowEx( 0, "WindowClass","A dialog window",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
400,100,200,200,
NULL,NULL,NULL,NULL
);
//making the window visible, showing the window
ShowWindow(hwnd, true);
//updating the window
UpdateWindow(hwnd);
//the window message loop
MSG msg;
while(GetMessage(&msg,NULL,0,0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
#define IDC_EDIT 101 //used to identify a control, or you could use an enum
HWND hEdit = CreateWindowEx(
0,
"EDIT",// class name
"Text Box",
BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
50,50,100,25,
hwnd,
(HMENU)IDC_EDIT, //the control identifier
NULL,NULL
);
//hEdit is the control handle, and it can be accessed from anywhere
HWND hEdit = GetDlgItem( hwnd, IDC_EDIT);
GetWindowText(hEdit,buffer,255);
SetWindowText(hEdit,"New Message");
//or
GetDlgItemText(hwnd, IDC_EDIT, buffer, 255)
SetDlgItemText(hwnd, IDC_TEXT, "This is a string");
#define IDC_BUTON 102 //used for identifying a button
CreateWindowEx(
0,
"BUTTON",// button class
"Button",
BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
50,50,100,25,
hwnd,
(HMENU)IDC_BUTON
,NULL,NULL
);
LRESULT WINAPI wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
//you can change the if into a switch
if(message == WM_COMMAND){
switch(wParam){
case IDC_BUTON:
MessageBox(hwnd,"Button Pressed","BTN WND",0);
break;
}
return 0;
}
}
switch(message) {
case WM_KEYDOWN: // If we get a key down message, do stuff
switch(wParam)
{
case VK_ESCAPE: // If they push ESC, close the app
SendMessage(hwnd, WM_CLOSE, 0, 0);
break;
case 'W':
case VK_UP: // If they push up, move forward (Camera's +Z)
gCamera->move(Camera::eForward, MoveSpeed);
break;
case 'S':
case VK_DOWN: // If they push down, move backward (Camera's -Z)
gCamera->move(Camera::eBack, MoveSpeed);
break;
case 'D':
case VK_RIGHT: // If they push right, move right (Camera's +X)
gCamera->move(Camera::eRight, MoveSpeed);
break;
case 'A':
case VK_LEFT: // If they push left, move left (Camera's -X)
gCamera->move(Camera::eLeft, MoveSpeed);
break;
case 'R':
gCamera->reset(); // Recenter the camera
break;
}
break;
}
case WM_MOUSEMOVE:
{
int xPos = GET_X_PARAM(lParam); //X absolute position
int yPos = GET_Y_PARAM(lParam); //Y absolute position
// ...
break;
}
Users browsing this forum: No registered users and 0 guests