I want to improve my code and file structure in large Win32 projects with many windows and controls. Currently, I tend to have one title and one source file for the entire implementation of a window or dialog. This is great for small projects, but now it has come to the point that these implementations begin to reach 1000-2000 lines, which is tedious to view.
A typical source file is as follows:
static LRESULT CALLBACK on_create(const HWND hwnd, WPARAM wp, LPARAM lp) {
setup_menu(hwnd);
setup_list(hwnd);
setup_context_menu(hwnd);
return 0;
}
static LRESULT CALLBACK on_notify(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) {
const NMHDR* header = (const NMHDR*)lp;
switch (header->idFrom) {
case IDC_WINDOW_LIST:
switch (header->code) {
case NM_RCLICK:
return on_window_list_right_click(hwnd, wp, lp);
}
}
}
static LRESULT CALLBACK wndmain_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) {
switch (msg) {
case WM_CREATE:
return on_create(hwnd, wp, lp);
case WM_CLOSE:
return on_close(hwnd, wp, lp);
case WM_NOTIFY:
return on_notify(hwnd, wp, lp);
default:
return DefWindowProc(hwnd, msg, wp, lp);
}
}
, , , , , , ..... , , .
Win32, , , , GUI, GUI Win32 , CreateWindowEx, proc .
, , .
!
- , , Win32 API .
, , , .