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
|
// Main.cpp
// cl Main.cpp /O1 /Os /GS- /FeTest.exe /link crt_win_a.obj memset.obj kernel32.lib user32.lib gdi32.lib // 4,096 Bytes
// cl Main.cpp /O1 /Os /GS- /FeTest.exe /link TCLib.lib kernel32.lib user32.lib gdi32.lib
// cl Main.cpp /O1 /Os /GS- /FeTest.exe /link kernel32.lib user32.lib gdi32.lib
// #define TCLib
#include <windows.h>
#ifdef TCLib
#include "stdio.h"
#else
#include <stdio.h>
#endif
//#include "memory.h"
#define IDC_OUTPUT 2005
FILE* fp=NULL;
LRESULT CALLBACK fnOutputScreenProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
if(msg==WM_SIZE)
{
RECT rc;
fprintf(fp," Entering fnOutputScreenProc() - WM_SIZE\n");
memset(&rc,0,sizeof(rc));
GetClientRect(hWnd,&rc);
fprintf(fp," rc.left = %d\n",rc.left);
fprintf(fp," rc.right = %d\n",rc.right);
fprintf(fp," rc.top = %d\n",rc.top);
fprintf(fp," rc.bottom = %d\n",rc.bottom);
fprintf(fp," Leaving fnOutputScreenProc() - WM_SIZE\n");
return 0;
}
return (DefWindowProc(hWnd, msg, wParam, lParam));
}
LRESULT CALLBACK fnWndProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
HINSTANCE hIns = NULL;
HWND hOutput = NULL;
WNDCLASSEX wc;
fp=fopen("Output.txt","w");
fprintf(fp,"Entering fnWndProc() - WM_CREATE\n");
fprintf(fp," hWnd = Ox%p\n",hWnd);
hIns=((LPCREATESTRUCT)lParam)->hInstance;
SetWindowLongPtr(hWnd,0,(LONG_PTR)hIns);
wc.lpszClassName = "Output_Screen", wc.lpfnWndProc = fnOutputScreenProc;
wc.hInstance = hIns, wc.style = CS_DBLCLKS;
wc.cbClsExtra = 0, wc.cbWndExtra = sizeof(void*);
wc.lpszMenuName = NULL, wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.hIcon = (HICON)LoadImage(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
wc.hIconSm = (HICON)LoadImage(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
wc.hCursor = (HCURSOR)LoadImage(NULL, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_SHARED);
wc.cbSize = sizeof(wc);
RegisterClassEx(&wc);
hOutput=CreateWindowEx
(
WS_EX_WINDOWEDGE,
"Output_Screen",
"Output Screen",
WS_CHILD|WS_VISIBLE|WS_SIZEBOX|WS_BORDER|WS_CAPTION,
0,0,200,100,
hWnd,
(HMENU)IDC_OUTPUT,
(HINSTANCE)GetWindowLongPtr(hWnd,0),
0
);
if(hOutput)
SetWindowLongPtr(hWnd,1*sizeof(void*),(LONG_PTR)hOutput);
fprintf(fp,"Leaving fnWndProc() - WM_CREATE\n\n");
return 0;
}
case WM_SIZE:
{
HWND hOutput=NULL;
RECT rc;
fprintf(fp,"Entering fnWndProc() - WM_SIZE\n");
memset(&rc,0,sizeof(rc));
GetClientRect(hWnd,&rc);
int iXDiff = rc.right - 625;
int iYDiff = rc.bottom - 600;
hOutput=(HWND)GetWindowLongPtr(hWnd,1*sizeof(void*));
if(hOutput)
{
memset(&rc,0,sizeof(rc));
GetClientRect(hOutput,&rc);
}
MoveWindow(GetDlgItem(hWnd,IDC_OUTPUT),10,10,200+iXDiff,100+iYDiff,TRUE);
fprintf(fp,"Leaving fnWndProc() - WM_SIZE\n\n");
return 0;
}
case WM_DESTROY:
{
fprintf(fp,"Entering fnWndProc() - WM_DESTROY\n");
fprintf(fp," hWnd = Ox%p\n",hWnd);
PostQuitMessage(0);
fprintf(fp,"Leaving fnWndProc() - WM_DESTROY\n");
fclose(fp);
return 0;
}
}
return (DefWindowProc(hWnd, msg, wParam, lParam));
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
{
MSG messages;
WNDCLASS wc;
wc.lpszClassName = "Form1", wc.lpfnWndProc = fnWndProc;
wc.hInstance = hInstance, wc.style = 0;
wc.cbClsExtra = 0, wc.cbWndExtra = 2*sizeof(void*);
wc.hIcon = NULL, wc.hCursor = NULL;
wc.lpszMenuName = NULL, wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
RegisterClass(&wc);
CreateWindow("Form1","Form1",WS_OVERLAPPEDWINDOW|WS_VISIBLE,100,100,625,600,HWND_DESKTOP,0,hInstance,0);
while(GetMessage(&messages,NULL,0,0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
| |