|
|
От: | DarkTranquillity | |
| Дата: | 25.02.09 09:24 | ||
| Оценка: | |||
_C>void main()
_C>{
_C>..............
_C> GetClassInfo(GetModuleHandle(NULL), L"STATIC", &wcls);
_C> CopyMemory(&wcl, &wcls, sizeof(WNDCLASS));
_C> wcl.hInstance = GetModuleHandle(NULL);
_C> wcl.lpszClassName = L"FTInfoWin";
_C> wcl.lpfnWndProc = (WNDPROC)WinDialogProc;
_C> wcl.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
_C> RegisterClass(&wcl);
_C> HWND hwnd = CreateWindow( L"FTInfoWin",
_C> L"",
_C> WS_CHILD,
_C> posx, posy,
_C> 15, 15,
_C> parent->HWnd(), // HWND чужого окна
_C> (HMENU)"",
_C> GetModuleHandle(NULL),
_C> NULL);
_C> if (hwnd)
_C> {
_C> ShowWindow(hwnd,SW_SHOW);
_C> UpdateWindow(hwnd);
_C> SetWindowPos(hwnd, HWND_TOPMOST, posx, posy, 15, 15, SWP_SHOWWINDOW);
_C> }
_C>...............
_C>}
_C>int CFTChildWindow::OnDraw()
_C>{
_C> PAINTSTRUCT ps;
_C> HDC hDC = GetDC(hWnd);
_C> SetBkColor(hDC, RGB(0,0,0));
_C> SetTextColor(hDC, RGB(0,255,0));
_C> wchar_t text[255];
_C> if (_itow(iValue, text, 10))
_C> TextOut(hDC, 0,0, text, wcslen(text));
_C> return 1;
_C>}
_C>LRESULT CALLBACK WinDialogProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
_C>{
_C> switch (msg)
_C> {
_C> case WM_PAINT:
_C> {
_C> LRESULT r = DefWindowProc(hWnd,msg,wParam,lParam);
_C> if (windows.find(hWnd)!=windows.end())
_C> {
_C> windows[hWnd]->OnDraw(); // рисуем наш контрол
_C> }
_C> return r;
_C> }
_C> break;
_C> }
_C>}
_C>Как нужно правильно делать?