First Window
This commit is contained in:
+105
@@ -0,0 +1,105 @@
|
||||
#ifndef INCLUDED_C_WINGUIAPP_H
|
||||
#define INCLUDED_C_WINGUIAPP_H
|
||||
|
||||
#ifndef INCLUDED_WINDOWS_H
|
||||
#define INCLUDED_WINDOWS_H
|
||||
#include <windows.h>
|
||||
#endif /*INCLUDED_WINDOWS_H*/
|
||||
|
||||
#ifndef INCLUDED_WINDOWSX_H
|
||||
#define INCLUDED_WINDOWSX_H
|
||||
#include <windowsx.h>
|
||||
#endif /*INCLUDED_WINDOWSX_H*/
|
||||
|
||||
#ifndef INCLUDED_STRING_H
|
||||
#define INCLUDED_STRING_H
|
||||
#include <string.h>
|
||||
#endif /*INCLUDED_STRING_H*/
|
||||
|
||||
#ifndef INCLUDED_STDLIB_H
|
||||
#define INCLUDED_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif /*INCLUDED_STDLIB_H*/
|
||||
|
||||
#ifndef INCLUDED_TIME_H
|
||||
#define INCLUDED_TIME_H
|
||||
#include <time.h>
|
||||
#endif /*INCLUDED_TIME_H*/
|
||||
|
||||
#ifndef INCLUDED_STDINT_H
|
||||
#define INCLUDED_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif /*INCLUDED_STDINT_H*/
|
||||
|
||||
#ifndef INCLUDED_STDBOOL_H
|
||||
#define INCLUDED_STDBOOL_H
|
||||
#include <stdbool.h>
|
||||
#endif /*INCLUDED_STDBOOL_H*/
|
||||
|
||||
#ifndef INCLUDED_STDATOMIC_H
|
||||
#define INCLUDED_STDATOMIC_H
|
||||
#include <stdatomic.h>
|
||||
#endif /*INCLUDED_STDATOMIC_H*/
|
||||
|
||||
#ifndef INCLUDED_STDDEF_H
|
||||
#define INCLUDED_STDDEF_H
|
||||
#include <stddef.h>
|
||||
#endif /*INCLUDED_STDDEF_H*/
|
||||
|
||||
#ifndef INCLUDED_INTTYPES_H
|
||||
#define INCLUDED_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif /*INCLUDED_INTTYPES_H*/
|
||||
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------------------------------------------- */
|
||||
/* */
|
||||
|
||||
typedef struct {
|
||||
HINSTANCE hInstance;
|
||||
HWND hMainWindow;
|
||||
}c_WinGuiApp_t;
|
||||
|
||||
typedef bool (*c_WinGuiApp_fRegister_t)(HINSTANCE hInstance);
|
||||
typedef HWND (*c_WinGuiApp_fCreate_t)(HINSTANCE hInstance, int nCmdShow);
|
||||
|
||||
extern c_WinGuiApp_t c_WinGuiApp;
|
||||
/* -------------------------------------------------------------------------------------------------------------- */
|
||||
/* */
|
||||
|
||||
#define c_WinGuiApp_Main(fRegister, fCreate) \
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow){ \
|
||||
MSG Msg; \
|
||||
if(!hPrevInstance){ \
|
||||
if(!fRegister(hInstance)){ \
|
||||
return FALSE; \
|
||||
} \
|
||||
} \
|
||||
c_WinGuiApp.hMainWindow = fCreate(hInstance, nCmdShow); \
|
||||
if(!c_WinGuiApp.hMainWindow){ \
|
||||
return FALSE; \
|
||||
} \
|
||||
while(GetMessage(&Msg, NULL, 0, 0)){ \
|
||||
TranslateMessage(&Msg); \
|
||||
DispatchMessage(&Msg); \
|
||||
} \
|
||||
return Msg.wParam; \
|
||||
}
|
||||
|
||||
#define c_WinGuiApp_OnEvent(msg, handler) case msg: return HANDLE_##msg(hWnd, wParam, lParam, handler);
|
||||
|
||||
#define c_WinGuiApp_EventBegin(name) \
|
||||
static LRESULT CALLBACK name(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam){ \
|
||||
switch (Message) {
|
||||
|
||||
|
||||
#define c_WinGuiApp_EventEnd\
|
||||
default: \
|
||||
return DefWindowProc(hWnd, Message, wParam, lParam); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#endif /*INCLUDED_C_WINGUIAPP_H*/
|
||||
Reference in New Issue
Block a user