1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
// cl Main.cpp /O1 /Os /FeForm1.exe /GS- TCLib.lib kernel32.lib user32.lib comctl32.lib
// cl Main.cpp /O1 /Os /MT /FeForm1.exe kernel32.lib user32.lib comctl32.lib
// 6,144 Bytes VC19 (Visual Studio 2015) x64 UNICODE TCLib.lib Linkage
// 123,904 Bytes VC19 (Visual Studio 2015) x64 UNICODE LIBCMT.LIB Linkage
//#define TCLib
#ifndef UNICODE
#define UNICODE
#endif
#ifndef _UNICODE
#define _UNICODE
#endif
#include <windows.h>
#include <commctrl.h>
#ifdef TCLib
#include "stdio.h"
#include "tchar.h"
#else
#include <cstdio>
#include <tchar.h>
#endif
#include "Form1.h"
LRESULT CALLBACK fnWndProc_Landscape(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
return 0;
}
case WM_DESTROY:
{
return 0;
}
}
return (DefWindowProc(hwnd,msg,wParam,lParam));
}
LRESULT CALLBACK frmExtRegenTab_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
return (DefWindowProc(hwnd,msg,wParam,lParam));
}
LRESULT CALLBACK fnWndProc_Residuals(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
return (DefWindowProc(hwnd,msg,wParam,lParam));
}
LRESULT CALLBACK fnWndProc_Interference(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
return (DefWindowProc(hwnd,msg,wParam,lParam));
}
LRESULT __stdcall fnWndProc_OnCreate(WndEventArgs& Wea)
{
INITCOMMONCONTROLSEX icx;
BOOL blnReturn=FALSE;
HWND hTabCtl=NULL;
HWND hTabs=NULL;
WNDCLASS wc;
TCHAR* szTabs[]=
{
_T("Landscape"),
_T("ExtRegen"),
_T("Residuals/Oak"),
_T("Interference")
};
RECT rcForm;
TCITEM tie;
fp=fopen("Output.txt","w");
if(!fp)
return -1;
fprintf(fp,"Entering fnWndProc_OnCreate()\n");
fprintf(fp," Wea.hWnd = %p\n",Wea.hWnd);
icx.dwSize=sizeof(icx);
icx.dwICC=ICC_TAB_CLASSES;
blnReturn=InitCommonControlsEx(&icx);
fprintf(fp," blnReturn = %d\n",blnReturn);
if(blnReturn)
{
// WC_TABCONTROL
//GetClientRect(Wea.hWnd,&rcForm);
//fprintf(fp," rcForm.right = %u\n",rcForm.right);
//fprintf(fp," rcForm.bottom = %u\n",rcForm.bottom);
hTabCtl=CreateWindow(WC_TABCONTROL, _T(""),WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE,10,10,465,340,Wea.hWnd,(HMENU)IDC_TAB,Wea.hInst,NULL);
fprintf(fp," hTabCtl = %p\n",hTabCtl);
// Register Tab Classes
wc.lpszClassName=szTabs[0]; wc.lpfnWndProc=fnWndProc_Landscape;
wc.style=0; wc.hIcon=NULL;
wc.hInstance=Wea.hInst; wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=(HBRUSH)COLOR_BTNSHADOW; wc.cbWndExtra=0;
wc.lpszMenuName=NULL; wc.cbClsExtra=0;
RegisterClass(&wc);
wc.lpszClassName=szTabs[1]; wc.lpfnWndProc=frmExtRegenTab_WndProc;
wc.style=0; wc.hIcon=NULL;
wc.hInstance=Wea.hInst; wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=(HBRUSH)COLOR_BTNSHADOW; wc.cbWndExtra=2*sizeof(void*);
wc.lpszMenuName=NULL; wc.cbClsExtra=0;
RegisterClass(&wc);
wc.lpszClassName=szTabs[2]; wc.lpfnWndProc=fnWndProc_Residuals;
wc.style=0; wc.hIcon=NULL;
wc.hInstance=Wea.hInst; wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=(HBRUSH)COLOR_BTNSHADOW; wc.cbWndExtra=sizeof(void*);
wc.lpszMenuName=NULL; wc.cbClsExtra=0;
RegisterClass(&wc);
wc.lpszClassName=szTabs[3]; wc.lpfnWndProc=fnWndProc_Interference;
wc.style=0; wc.hIcon=NULL;
wc.hInstance=Wea.hInst; wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=(HBRUSH)COLOR_BTNSHADOW; wc.cbWndExtra=sizeof(void*);
wc.lpszMenuName=NULL; wc.cbClsExtra=0;
RegisterClass(&wc);
for(size_t i=0; i<sizeof(szTabs)/sizeof(szTabs[0]); i++)
{
tie.mask = TCIF_TEXT | TCIF_IMAGE;
tie.iImage = -1;
tie.pszText = szTabs[i];
TabCtrl_InsertItem(hTabCtl, i, &tie);
}
}
fprintf(fp,"Leaving fnWndProc_OnCreate()\n\n");
return 0;
}
LRESULT __stdcall fnWndProc_OnCommand(WndEventArgs& Wea)
{
fprintf(fp,"Entering fnWndProc_OnCommand()\n");
fprintf(fp," Wea.hWnd = %p\n",Wea.hWnd);
fprintf(fp,"Leaving fnWndProc_OnCommand()\n\n");
return 0;
}
LRESULT __stdcall fnWndProc_OnNotify(WndEventArgs& Wea)
{
//fprintf(fp,"Entering fnWndProc_OnNotify()\n");
//fprintf(fp," Wea.hWnd = %p\n",Wea.hWnd);
//fprintf(fp,"Leaving fnWndProc_OnNotify()\n\n");
return 0;
}
LRESULT __stdcall fnWndProc_OnDestroy(WndEventArgs& Wea)
{
fprintf(fp,"Entering fnWndProc_OnDestroy()\n");
fprintf(fp," Wea.hWnd = %p\n",Wea.hWnd);
fprintf(fp,"Leaving fnWndProc_OnDestroy()");
fclose(fp);
PostQuitMessage(0);
return 0;
}
LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
WndEventArgs Wea;
for(unsigned int i=0; i<dim(EventHandler); i++)
{
if(EventHandler[i].Code==msg)
{
Wea.hWnd=hwnd,Wea.lParam=lParam,Wea.wParam=wParam;
return (*EventHandler[i].fnPtr)(Wea);
}
}
return (DefWindowProc(hwnd,msg,wParam,lParam));
}
int WINAPI WinMain(HINSTANCE hIns, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
{
TCHAR szClassName[]=_T("Form1");
HWND hWnd=NULL;
DWORD dwStyle;
WNDCLASS wc;
MSG msg;
wc.hInstance=hIns; wc.lpszClassName=szClassName;
wc.lpfnWndProc=fnWndProc; wc.style=0;
wc.hIcon=NULL; wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.lpszMenuName=NULL; wc.cbClsExtra=0;
wc.cbWndExtra=0; wc.hbrBackground=(HBRUSH)COLOR_BTNSHADOW;
RegisterClass(&wc);
dwStyle=WS_OVERLAPPED|WS_SYSMENU|WS_VISIBLE;
hWnd=CreateWindow(szClassName,_T("Windows App"),dwStyle,400,400,500,400,HWND_DESKTOP,0,hIns,0);
if(hWnd)
{
ShowWindow(hWnd,iShow);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
|