Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenwelcome.c
Go to the documentation of this file.
00001 /* 00002 * ReactOS applications 00003 * Copyright (C) 2001, 2002, 2003 ReactOS Team 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 /* $Id: welcome.c 53717 2011-09-15 21:26:32Z jgardou $ 00020 * 00021 * COPYRIGHT: See COPYING in the top level directory 00022 * PROJECT: ReactOS welcome/autorun application 00023 * FILE: subsys/system/welcome/welcome.c 00024 * PROGRAMMERS: Eric Kohl 00025 * Casper S. Hornstrup (chorns@users.sourceforge.net) 00026 * 00027 * NOTE: 00028 * This utility can be customized by modifying the resources. 00029 * Please do NOT change the source code in order to customize this 00030 * utility but change the resources! 00031 */ 00032 00033 #include <reactos/version.h> 00034 #include <windows.h> 00035 #include <string.h> 00036 #include <stdio.h> 00037 #include <tchar.h> 00038 00039 #include "resource.h" 00040 00041 00042 00043 #define LIGHT_BLUE 0x00F7EFD6 00044 #define DARK_BLUE 0x008C7B6B 00045 00046 #define TITLE_WIDTH 480 00047 #define TITLE_HEIGHT 93 00048 00049 00050 /* GLOBALS ******************************************************************/ 00051 00052 TCHAR szFrameClass [] = TEXT("WelcomeWindowClass"); 00053 TCHAR szAppTitle [80]; 00054 00055 HINSTANCE hInstance; 00056 00057 HWND hwndMain = 0; 00058 HWND hwndDefaultTopic = 0; 00059 00060 HDC hdcMem = 0; 00061 00062 int nTopic = -1; 00063 int nDefaultTopic = -1; 00064 00065 ULONG ulInnerWidth = TITLE_WIDTH; 00066 ULONG ulInnerHeight = (TITLE_WIDTH * 3) / 4; 00067 ULONG ulTitleHeight = TITLE_HEIGHT + 3; 00068 00069 HBITMAP hTitleBitmap = 0; 00070 HBITMAP hDefaultTopicBitmap = 0; 00071 HBITMAP hTopicBitmap[10]; 00072 HWND hwndTopicButton[10]; 00073 HWND hwndCloseButton; 00074 HWND hwndCheckButton; 00075 00076 HFONT hfontTopicButton; 00077 HFONT hfontTopicTitle; 00078 HFONT hfontTopicDescription; 00079 HFONT hfontCheckButton; 00080 00081 HBRUSH hbrLightBlue; 00082 HBRUSH hbrDarkBlue; 00083 HBRUSH hbrRightPanel; 00084 00085 RECT rcTitlePanel; 00086 RECT rcLeftPanel; 00087 RECT rcRightPanel; 00088 00089 WNDPROC fnOldBtn; 00090 00091 00092 INT_PTR CALLBACK 00093 MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 00094 00095 00096 /* FUNCTIONS ****************************************************************/ 00097 00098 int WINAPI 00099 _tWinMain(HINSTANCE hInst, 00100 HINSTANCE hPrevInstance, 00101 LPTSTR lpszCmdLine, 00102 int nCmdShow) 00103 { 00104 WNDCLASSEX wndclass; 00105 MSG msg; 00106 int xPos; 00107 int yPos; 00108 int xWidth; 00109 int yHeight; 00110 RECT rcWindow; 00111 HICON hMainIcon; 00112 HMENU hSystemMenu; 00113 DWORD dwStyle = WS_OVERLAPPED | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | 00114 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; 00115 BITMAP BitmapInfo; 00116 00117 UNREFERENCED_PARAMETER(hPrevInstance); 00118 UNREFERENCED_PARAMETER(lpszCmdLine); 00119 00120 hInstance = hInst; 00121 00122 /* Load icons */ 00123 hMainIcon = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_MAIN)); 00124 00125 /* Register the window class */ 00126 wndclass.style = CS_HREDRAW | CS_VREDRAW; 00127 wndclass.lpfnWndProc = (WNDPROC)MainWndProc; 00128 wndclass.cbClsExtra = 0; 00129 wndclass.cbWndExtra = 0; 00130 wndclass.hInstance = hInstance; 00131 wndclass.hIcon = hMainIcon; 00132 wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); 00133 wndclass.hbrBackground = 0; 00134 wndclass.lpszMenuName = NULL; 00135 wndclass.lpszClassName = szFrameClass; 00136 00137 wndclass.cbSize = sizeof(WNDCLASSEX); 00138 wndclass.hIconSm = 0; 00139 00140 RegisterClassEx(&wndclass); 00141 00142 hTitleBitmap = LoadBitmap (hInstance, MAKEINTRESOURCE(IDB_TITLEBITMAP)); 00143 if (hTitleBitmap != NULL) 00144 { 00145 GetObject(hTitleBitmap, sizeof(BITMAP), &BitmapInfo); 00146 ulInnerWidth = BitmapInfo.bmWidth; 00147 ulInnerHeight = (ulInnerWidth * 3) / 4; 00148 ulTitleHeight = BitmapInfo.bmHeight + 3; 00149 DeleteObject(hTitleBitmap); 00150 } 00151 ulInnerHeight -= GetSystemMetrics(SM_CYCAPTION); 00152 00153 rcWindow.top = 0; 00154 rcWindow.bottom = ulInnerHeight - 1; 00155 rcWindow.left = 0; 00156 rcWindow.right = ulInnerWidth - 1; 00157 00158 AdjustWindowRect(&rcWindow, 00159 dwStyle, 00160 FALSE); 00161 xWidth = rcWindow.right - rcWindow.left; 00162 yHeight = rcWindow.bottom - rcWindow.top; 00163 00164 xPos = (GetSystemMetrics(SM_CXSCREEN) - xWidth) / 2; 00165 yPos = (GetSystemMetrics(SM_CYSCREEN) - yHeight) / 2; 00166 00167 rcTitlePanel.top = 0; 00168 rcTitlePanel.bottom = ulTitleHeight; 00169 rcTitlePanel.left = 0; 00170 rcTitlePanel.right = ulInnerWidth - 1; 00171 00172 rcLeftPanel.top = rcTitlePanel.bottom; 00173 rcLeftPanel.bottom = ulInnerHeight - 1; 00174 rcLeftPanel.left = 0; 00175 rcLeftPanel.right = ulInnerWidth / 3; 00176 00177 rcRightPanel.top = rcLeftPanel.top; 00178 rcRightPanel.bottom = rcLeftPanel.bottom; 00179 rcRightPanel.left = rcLeftPanel.right; 00180 rcRightPanel.right = ulInnerWidth - 1; 00181 00182 if (!LoadString(hInstance, (UINT_PTR)MAKEINTRESOURCE(IDS_APPTITLE), szAppTitle, 80)) 00183 _tcscpy(szAppTitle, TEXT("ReactOS Welcome")); 00184 00185 /* Create main window */ 00186 hwndMain = CreateWindow(szFrameClass, 00187 szAppTitle, 00188 dwStyle, 00189 xPos, 00190 yPos, 00191 xWidth, 00192 yHeight, 00193 0, 00194 0, 00195 hInstance, 00196 NULL); 00197 00198 hSystemMenu = GetSystemMenu(hwndMain, FALSE); 00199 if(hSystemMenu) 00200 { 00201 RemoveMenu(hSystemMenu, SC_SIZE, MF_BYCOMMAND); 00202 RemoveMenu(hSystemMenu, SC_MAXIMIZE, MF_BYCOMMAND); 00203 } 00204 00205 ShowWindow(hwndMain, nCmdShow); 00206 UpdateWindow(hwndMain); 00207 00208 while (GetMessage(&msg, NULL, 0, 0) != FALSE) 00209 { 00210 TranslateMessage(&msg); 00211 DispatchMessage(&msg); 00212 } 00213 00214 return(msg.wParam); 00215 } 00216 00217 00218 INT_PTR CALLBACK 00219 ButtonSubclassWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 00220 { 00221 LONG i; 00222 00223 if (uMsg == WM_MOUSEMOVE) 00224 { 00225 i = GetWindowLongPtr(hWnd, GWL_ID); 00226 if (nTopic != i) 00227 { 00228 nTopic = i; 00229 SetFocus(hWnd); 00230 InvalidateRect(hwndMain, &rcRightPanel, TRUE); 00231 } 00232 } 00233 00234 return(CallWindowProc(fnOldBtn, hWnd, uMsg, wParam, lParam)); 00235 } 00236 00237 00238 static BOOL 00239 RunApplication(int nTopic) 00240 { 00241 PROCESS_INFORMATION ProcessInfo; 00242 STARTUPINFO StartupInfo; 00243 TCHAR AppName[256]; 00244 TCHAR CurrentDir[256]; 00245 int nLength; 00246 00247 InvalidateRect(hwndMain, NULL, TRUE); 00248 00249 GetCurrentDirectory(256, CurrentDir); 00250 00251 nLength = LoadString(hInstance, IDS_TOPICACTION0 + nTopic, AppName, 256); 00252 if (nLength == 0) 00253 return TRUE; 00254 00255 if (!_tcsicmp(AppName, TEXT("<exit>"))) 00256 return FALSE; 00257 00258 if (_tcsicmp(AppName, TEXT("explorer.exe")) == 0) 00259 { 00260 _tcscat(AppName, TEXT(" ")); 00261 _tcscat(AppName, CurrentDir); 00262 } 00263 00264 memset(&StartupInfo, 0, sizeof(STARTUPINFO)); 00265 StartupInfo.cb = sizeof(STARTUPINFO); 00266 StartupInfo.lpTitle = TEXT("Test"); 00267 StartupInfo.dwFlags = STARTF_USESHOWWINDOW; 00268 StartupInfo.wShowWindow = SW_SHOWNORMAL; 00269 00270 CreateProcess(NULL, AppName, NULL, NULL, FALSE, CREATE_NEW_CONSOLE,NULL, 00271 CurrentDir, 00272 &StartupInfo, 00273 &ProcessInfo); 00274 00275 CloseHandle(ProcessInfo.hProcess); 00276 CloseHandle(ProcessInfo.hThread); 00277 00278 return TRUE; 00279 } 00280 00281 00282 static VOID 00283 SubclassButton(HWND hWnd) 00284 { 00285 fnOldBtn = (WNDPROC)SetWindowLongPtr(hWnd, GWL_WNDPROC, (DWORD_PTR)ButtonSubclassWndProc); 00286 } 00287 00288 00289 static DWORD 00290 GetButtonHeight(HDC hDC, 00291 HFONT hFont, 00292 LPCTSTR szText, 00293 DWORD dwWidth) 00294 { 00295 HFONT hOldFont; 00296 RECT rect; 00297 00298 rect.left = 0; 00299 rect.right = dwWidth - 20; 00300 rect.top = 0; 00301 rect.bottom = 25; 00302 00303 hOldFont = (HFONT) SelectObject(hDC, hFont); 00304 DrawText(hDC, szText, -1, &rect, DT_TOP | DT_CALCRECT | DT_WORDBREAK); 00305 SelectObject(hDC, hOldFont); 00306 00307 return(rect.bottom-rect.top + 14); 00308 } 00309 00310 00311 static LRESULT 00312 OnCreate(HWND hWnd, WPARAM wParam, LPARAM lParam) 00313 { 00314 TCHAR szText[80]; 00315 int i,nLength; 00316 HDC ScreenDC; 00317 DWORD dwTop; 00318 DWORD dwHeight = 0; 00319 00320 UNREFERENCED_PARAMETER(wParam); 00321 UNREFERENCED_PARAMETER(lParam); 00322 00323 hbrLightBlue = CreateSolidBrush(LIGHT_BLUE); 00324 hbrDarkBlue = CreateSolidBrush(DARK_BLUE); 00325 hbrRightPanel = CreateSolidBrush(0x00FFFFFF); 00326 00327 /* Topic title font */ 00328 hfontTopicTitle = CreateFont(-18,0,0,0,FW_NORMAL, 00329 FALSE,FALSE,FALSE,ANSI_CHARSET, 00330 OUT_DEFAULT_PRECIS, 00331 CLIP_DEFAULT_PRECIS, 00332 DEFAULT_QUALITY, 00333 FF_DONTCARE, 00334 TEXT("Arial")); 00335 00336 /* Topic description font */ 00337 hfontTopicDescription = CreateFont(-11,0,0,0,FW_THIN, 00338 FALSE,FALSE,FALSE,ANSI_CHARSET, 00339 OUT_DEFAULT_PRECIS, 00340 CLIP_DEFAULT_PRECIS, 00341 DEFAULT_QUALITY, 00342 FF_DONTCARE, 00343 TEXT("Arial")); 00344 00345 /* Topic button font */ 00346 hfontTopicButton = CreateFont(-11,0,0,0,FW_BOLD, 00347 FALSE,FALSE,FALSE,ANSI_CHARSET, 00348 OUT_DEFAULT_PRECIS, 00349 CLIP_DEFAULT_PRECIS, 00350 DEFAULT_QUALITY, 00351 FF_DONTCARE, 00352 TEXT("Arial")); 00353 00354 /* Load title bitmap */ 00355 if (hTitleBitmap != 0) 00356 hTitleBitmap = LoadBitmap (hInstance, MAKEINTRESOURCE(IDB_TITLEBITMAP)); 00357 00358 /* Load topic bitmaps */ 00359 hDefaultTopicBitmap = LoadBitmap (hInstance, MAKEINTRESOURCE(IDB_DEFAULTTOPICBITMAP)); 00360 for (i=0;i < 10; i++) 00361 { 00362 hTopicBitmap[i] = LoadBitmap (hInstance, MAKEINTRESOURCE(IDB_TOPICBITMAP0+i)); 00363 } 00364 00365 ScreenDC = GetWindowDC(hWnd); 00366 hdcMem = CreateCompatibleDC (ScreenDC); 00367 ReleaseDC(hWnd, ScreenDC); 00368 00369 /* load and create buttons */ 00370 dwTop = rcLeftPanel.top; 00371 for (i = 0; i < 10; i++) 00372 { 00373 nLength = LoadString(hInstance, IDS_TOPICBUTTON0 + i, szText, 80); 00374 if (nLength > 0) 00375 { 00376 dwHeight = GetButtonHeight(hdcMem, 00377 hfontTopicButton, 00378 szText, 00379 rcLeftPanel.right - rcLeftPanel.left); 00380 00381 hwndTopicButton[i] = CreateWindow(TEXT("BUTTON"), 00382 szText, 00383 WS_CHILDWINDOW | WS_VISIBLE | WS_TABSTOP | BS_MULTILINE | BS_OWNERDRAW, 00384 rcLeftPanel.left, 00385 dwTop, 00386 rcLeftPanel.right - rcLeftPanel.left, 00387 dwHeight, 00388 hWnd, 00389 (HMENU)IntToPtr(i), 00390 hInstance, 00391 NULL); 00392 hwndDefaultTopic = hwndTopicButton[i]; 00393 nDefaultTopic = i; 00394 SubclassButton(hwndTopicButton[i]); 00395 SendMessage(hwndTopicButton[i], WM_SETFONT, (WPARAM)hfontTopicButton, MAKELPARAM(TRUE,0)); 00396 } 00397 else 00398 { 00399 hwndTopicButton[i] = 0; 00400 } 00401 00402 dwTop += dwHeight; 00403 } 00404 00405 /* Create exit button */ 00406 nLength = LoadString(hInstance, IDS_CLOSETEXT, szText, 80); 00407 if (nLength > 0) 00408 { 00409 hwndCloseButton = CreateWindow(TEXT("BUTTON"), 00410 szText, 00411 WS_VISIBLE | WS_CHILD | BS_FLAT, 00412 rcRightPanel.right - 10 - 57, 00413 rcRightPanel.bottom - 10 - 21, 00414 57, 00415 21, 00416 hWnd, 00417 (HMENU)IDC_CLOSEBUTTON, 00418 hInstance, 00419 NULL); 00420 hwndDefaultTopic = 0; 00421 nDefaultTopic = -1; 00422 SendMessage(hwndCloseButton, WM_SETFONT, (WPARAM)hfontTopicButton, MAKELPARAM(TRUE,0)); 00423 } 00424 else 00425 { 00426 hwndCloseButton = 0; 00427 } 00428 00429 /* Create checkbox */ 00430 nLength = LoadString(hInstance, IDS_CHECKTEXT,szText,80); 00431 if (nLength > 0) 00432 { 00433 hfontCheckButton = CreateFont(-10,0,0,0,FW_THIN,FALSE,FALSE,FALSE,ANSI_CHARSET, 00434 OUT_DEFAULT_PRECIS, 00435 CLIP_DEFAULT_PRECIS, 00436 DEFAULT_QUALITY, 00437 FF_DONTCARE, 00438 TEXT("Tahoma")); 00439 00440 hwndCheckButton = CreateWindow(TEXT("BUTTON"), 00441 szText, 00442 WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX, 00443 rcLeftPanel.left + 8, 00444 rcLeftPanel.bottom - 8 - 13, 00445 rcLeftPanel.right - rcLeftPanel.left - 16, 00446 13, 00447 hWnd, 00448 (HMENU)IDC_CHECKBUTTON, 00449 hInstance, 00450 NULL); 00451 SendMessage(hwndCheckButton, WM_SETFONT, (WPARAM)hfontCheckButton, MAKELPARAM(TRUE,0)); 00452 } 00453 else 00454 { 00455 hwndCheckButton = 0; 00456 hfontCheckButton = 0; 00457 } 00458 00459 return 0; 00460 } 00461 00462 00463 static LRESULT 00464 OnCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) 00465 { 00466 UNREFERENCED_PARAMETER(lParam); 00467 00468 if (LOWORD(wParam) == IDC_CLOSEBUTTON) 00469 { 00470 DestroyWindow(hWnd); 00471 } 00472 else if ((LOWORD(wParam) < 10)) 00473 { 00474 if (RunApplication(LOWORD(wParam)) == FALSE) 00475 { 00476 DestroyWindow(hWnd); 00477 } 00478 } 00479 return 0; 00480 } 00481 00482 00483 static VOID 00484 PaintBanner(HDC hdc, LPRECT rcPanel) 00485 { 00486 HBITMAP hOldBitmap; 00487 HBRUSH hOldBrush; 00488 00489 /* Title bitmap */ 00490 hOldBitmap = (HBITMAP) SelectObject(hdcMem, hTitleBitmap); 00491 BitBlt(hdc, 00492 rcPanel->left, 00493 rcPanel->top, 00494 rcPanel->right - rcPanel->left, 00495 rcPanel->bottom - 3, 00496 hdcMem, 0, 0, SRCCOPY); 00497 SelectObject(hdcMem, hOldBitmap); 00498 00499 /* Dark blue line */ 00500 hOldBrush = (HBRUSH) SelectObject(hdc, hbrDarkBlue); 00501 PatBlt(hdc, 00502 rcPanel->left, 00503 rcPanel->bottom - 3, 00504 rcPanel->right - rcPanel->left, 00505 3, 00506 PATCOPY); 00507 00508 SelectObject(hdc, hOldBrush); 00509 } 00510 00511 00512 static LRESULT 00513 OnPaint(HWND hWnd, WPARAM wParam, LPARAM lParam) 00514 { 00515 HPEN hPen; 00516 HPEN hOldPen; 00517 HDC hdc; 00518 PAINTSTRUCT ps; 00519 HBITMAP hOldBitmap = 0; 00520 HBRUSH hOldBrush; 00521 HFONT hOldFont; 00522 RECT rcTitle, rcDescription; 00523 TCHAR szTopicTitle[80]; 00524 TCHAR szTopicDesc[256]; 00525 int nLength; 00526 BITMAP bmpInfo; 00527 TCHAR version[50]; 00528 00529 UNREFERENCED_PARAMETER(wParam); 00530 UNREFERENCED_PARAMETER(lParam); 00531 00532 hdc = BeginPaint(hWnd, &ps); 00533 00534 /* Banner panel */ 00535 PaintBanner(hdc, &rcTitlePanel); 00536 00537 /* Left panel */ 00538 hOldBrush = (HBRUSH) SelectObject (hdc, hbrLightBlue); 00539 PatBlt(hdc, 00540 rcLeftPanel.left, 00541 rcLeftPanel.top, 00542 rcLeftPanel.right - rcLeftPanel.left, 00543 rcLeftPanel.bottom - rcLeftPanel.top, 00544 PATCOPY); 00545 SelectObject(hdc, hOldBrush); 00546 00547 /* Right panel */ 00548 hOldBrush = (HBRUSH) SelectObject (hdc, WHITE_BRUSH); 00549 PatBlt(hdc, 00550 rcRightPanel.left, 00551 rcRightPanel.top, 00552 rcRightPanel.right - rcRightPanel.left, 00553 rcRightPanel.bottom - rcRightPanel.top, 00554 PATCOPY); 00555 SelectObject(hdc, hOldBrush); 00556 00557 /* Draw dark verical line */ 00558 hPen = CreatePen(PS_SOLID, 0, DARK_BLUE); 00559 hOldPen = (HPEN) SelectObject(hdc, hPen); 00560 MoveToEx(hdc, rcRightPanel.left, rcRightPanel.top, NULL); 00561 LineTo(hdc, rcRightPanel.left, rcRightPanel.bottom); 00562 SelectObject(hdc, hOldPen); 00563 DeleteObject(hPen); 00564 00565 /* Draw topic bitmap */ 00566 if ((nTopic == -1) && (hDefaultTopicBitmap != 0)) 00567 { 00568 GetObject(hDefaultTopicBitmap, sizeof(BITMAP), &bmpInfo); 00569 hOldBitmap = (HBITMAP) SelectObject (hdcMem, hDefaultTopicBitmap); 00570 BitBlt(hdc, 00571 rcRightPanel.right - bmpInfo.bmWidth, 00572 rcRightPanel.bottom - bmpInfo.bmHeight, 00573 bmpInfo.bmWidth, 00574 bmpInfo.bmHeight, 00575 hdcMem, 00576 0, 00577 0, 00578 SRCCOPY); 00579 } 00580 else if ((nTopic != -1) && (hTopicBitmap[nTopic] != 0)) 00581 { 00582 GetObject(hTopicBitmap[nTopic], sizeof(BITMAP), &bmpInfo); 00583 hOldBitmap = (HBITMAP) SelectObject (hdcMem, hTopicBitmap[nTopic]); 00584 BitBlt(hdc, 00585 rcRightPanel.right - bmpInfo.bmWidth, 00586 rcRightPanel.bottom - bmpInfo.bmHeight, 00587 bmpInfo.bmWidth, 00588 bmpInfo.bmHeight, 00589 hdcMem, 00590 0, 00591 0, 00592 SRCCOPY); 00593 } 00594 00595 if (nTopic == -1) 00596 { 00597 nLength = LoadString(hInstance, IDS_DEFAULTTOPICTITLE, szTopicTitle, 80); 00598 } 00599 else 00600 { 00601 nLength = LoadString(hInstance, IDS_TOPICTITLE0 + nTopic, szTopicTitle, 80); 00602 if (nLength == 0) 00603 nLength = LoadString(hInstance, IDS_DEFAULTTOPICTITLE, szTopicTitle, 80); 00604 } 00605 00606 if (nTopic == -1) 00607 { 00608 nLength = LoadString(hInstance, IDS_DEFAULTTOPICDESC, szTopicDesc, 256); 00609 } 00610 else 00611 { 00612 nLength = LoadString(hInstance, IDS_TOPICDESC0 + nTopic, szTopicDesc, 256); 00613 if (nLength == 0) 00614 nLength = LoadString(hInstance, IDS_DEFAULTTOPICDESC, szTopicDesc, 256); 00615 } 00616 00617 SetBkMode(hdc, TRANSPARENT); 00618 00619 /* Draw version information */ 00620 wsprintf(version, TEXT("ReactOS %d.%d.%d"), 00621 KERNEL_VERSION_MAJOR, 00622 KERNEL_VERSION_MINOR, 00623 KERNEL_VERSION_PATCH_LEVEL); 00624 00625 rcTitle.left = rcLeftPanel.left + 8; 00626 rcTitle.right = rcLeftPanel.right - 5; 00627 rcTitle.top = rcLeftPanel.bottom - 40; 00628 rcTitle.bottom = rcLeftPanel.bottom - 5; 00629 hOldFont = (HFONT) SelectObject(hdc, hfontTopicDescription); 00630 DrawText(hdc, version, -1, &rcTitle, DT_BOTTOM | DT_CALCRECT | DT_SINGLELINE); 00631 DrawText(hdc, version, -1, &rcTitle, DT_BOTTOM | DT_SINGLELINE); 00632 SelectObject(hdc, hOldFont); 00633 00634 /* Draw topic title */ 00635 rcTitle.left = rcRightPanel.left + 12; 00636 rcTitle.right = rcRightPanel.right - 8; 00637 rcTitle.top = rcRightPanel.top + 8; 00638 rcTitle.bottom = rcTitle.top + 57; 00639 hOldFont = (HFONT) SelectObject(hdc, hfontTopicTitle); 00640 DrawText(hdc, szTopicTitle, -1, &rcTitle, DT_TOP | DT_CALCRECT); 00641 00642 SetTextColor(hdc, DARK_BLUE); 00643 DrawText(hdc, szTopicTitle, -1, &rcTitle, DT_TOP); 00644 00645 /* Draw topic description */ 00646 rcDescription.left = rcRightPanel.left + 12; 00647 rcDescription.right = rcRightPanel.right - 8; 00648 rcDescription.top = rcTitle.bottom + 8; 00649 rcDescription.bottom = rcRightPanel.bottom - 20; 00650 00651 SelectObject(hdc, hfontTopicDescription); 00652 SetTextColor(hdc, 0x00000000); 00653 DrawText(hdc, szTopicDesc, -1, &rcDescription, DT_TOP | DT_WORDBREAK); 00654 00655 SetBkMode(hdc, OPAQUE); 00656 SelectObject(hdc, hOldFont); 00657 00658 SelectObject (hdcMem, hOldBrush); 00659 SelectObject (hdcMem, hOldBitmap); 00660 00661 EndPaint(hWnd, &ps); 00662 00663 return 0; 00664 } 00665 00666 00667 static LRESULT 00668 OnDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam) 00669 { 00670 LPDRAWITEMSTRUCT lpDis = (LPDRAWITEMSTRUCT)lParam; 00671 HPEN hPen, hOldPen; 00672 HBRUSH hOldBrush; 00673 TCHAR szText[80]; 00674 int iBkMode; 00675 00676 UNREFERENCED_PARAMETER(hWnd); 00677 UNREFERENCED_PARAMETER(wParam); 00678 00679 if (lpDis->hwndItem == hwndCloseButton) 00680 { 00681 DrawFrameControl(lpDis->hDC, 00682 &lpDis->rcItem, 00683 DFC_BUTTON, 00684 DFCS_BUTTONPUSH | DFCS_FLAT); 00685 } 00686 else 00687 { 00688 if (lpDis->CtlID == (ULONG)nTopic) 00689 hOldBrush = (HBRUSH) SelectObject(lpDis->hDC, hbrRightPanel); 00690 else 00691 hOldBrush = (HBRUSH) SelectObject(lpDis->hDC, hbrLightBlue); 00692 00693 PatBlt(lpDis->hDC, 00694 lpDis->rcItem.left, 00695 lpDis->rcItem.top, 00696 lpDis->rcItem.right, 00697 lpDis->rcItem.bottom, 00698 PATCOPY); 00699 SelectObject(lpDis->hDC, hOldBrush); 00700 00701 hPen = CreatePen(PS_SOLID, 0, DARK_BLUE); 00702 hOldPen = (HPEN) SelectObject(lpDis->hDC, hPen); 00703 MoveToEx(lpDis->hDC, lpDis->rcItem.left, lpDis->rcItem.bottom-1, NULL); 00704 LineTo(lpDis->hDC, lpDis->rcItem.right, lpDis->rcItem.bottom-1); 00705 SelectObject(lpDis->hDC, hOldPen); 00706 DeleteObject(hPen); 00707 00708 InflateRect(&lpDis->rcItem, -10, -4); 00709 OffsetRect(&lpDis->rcItem, 0, 1); 00710 GetWindowText(lpDis->hwndItem, szText, 80); 00711 SetTextColor(lpDis->hDC, 0x00000000); 00712 iBkMode = SetBkMode(lpDis->hDC, TRANSPARENT); 00713 DrawText(lpDis->hDC, szText, -1, &lpDis->rcItem, DT_TOP | DT_LEFT | DT_WORDBREAK); 00714 SetBkMode(lpDis->hDC, iBkMode); 00715 } 00716 00717 return 0; 00718 } 00719 00720 00721 static LRESULT 00722 OnMouseMove(HWND hWnd, WPARAM wParam, LPARAM lParam) 00723 { 00724 UNREFERENCED_PARAMETER(wParam); 00725 UNREFERENCED_PARAMETER(lParam); 00726 00727 if (nTopic != -1) 00728 { 00729 nTopic = -1; 00730 SetFocus(hWnd); 00731 InvalidateRect(hwndMain, &rcRightPanel, TRUE); 00732 } 00733 00734 return 0; 00735 } 00736 00737 00738 static LRESULT 00739 OnCtlColorStatic(HWND hWnd, WPARAM wParam, LPARAM lParam) 00740 { 00741 UNREFERENCED_PARAMETER(hWnd); 00742 00743 if ((HWND)lParam == hwndCheckButton) 00744 { 00745 SetBkColor((HDC)wParam, LIGHT_BLUE); 00746 return((LRESULT)hbrLightBlue); 00747 } 00748 00749 return 0; 00750 } 00751 00752 00753 static LRESULT 00754 OnActivate(HWND hWnd, WPARAM wParam, LPARAM lParam) 00755 { 00756 UNREFERENCED_PARAMETER(hWnd); 00757 UNREFERENCED_PARAMETER(wParam); 00758 UNREFERENCED_PARAMETER(lParam); 00759 nTopic = -1; 00760 InvalidateRect(hwndMain, &rcRightPanel, TRUE); 00761 00762 return(0); 00763 } 00764 00765 00766 static LRESULT 00767 OnDestroy(HWND hWnd, WPARAM wParam, LPARAM lParam) 00768 { 00769 int i; 00770 00771 UNREFERENCED_PARAMETER(hWnd); 00772 UNREFERENCED_PARAMETER(wParam); 00773 UNREFERENCED_PARAMETER(lParam); 00774 00775 for (i=0;i<10;i++) 00776 { 00777 if (hwndTopicButton[i] != 0) 00778 DestroyWindow(hwndTopicButton[i]); 00779 } 00780 00781 if (hwndCloseButton != 0) 00782 DestroyWindow(hwndCloseButton); 00783 00784 if (hwndCheckButton != 0) 00785 DestroyWindow(hwndCheckButton); 00786 00787 DeleteDC(hdcMem); 00788 00789 /* delete bitmaps */ 00790 DeleteObject(hDefaultTopicBitmap); 00791 DeleteObject(hTitleBitmap); 00792 for (i=0;i<10;i++) 00793 { 00794 if (hTopicBitmap[i] != 0) 00795 DeleteObject(hTopicBitmap[i]); 00796 } 00797 00798 DeleteObject(hfontTopicTitle); 00799 DeleteObject(hfontTopicDescription); 00800 DeleteObject(hfontTopicButton); 00801 00802 if (hfontCheckButton != 0) 00803 DeleteObject(hfontCheckButton); 00804 00805 DeleteObject(hbrLightBlue); 00806 DeleteObject(hbrDarkBlue); 00807 DeleteObject(hbrRightPanel); 00808 00809 return 0; 00810 } 00811 00812 00813 INT_PTR CALLBACK 00814 MainWndProc(HWND hWnd, 00815 UINT uMsg, 00816 WPARAM wParam, 00817 LPARAM lParam) 00818 { 00819 switch(uMsg) 00820 { 00821 case WM_CREATE: 00822 return(OnCreate(hWnd, wParam, lParam)); 00823 00824 case WM_COMMAND: 00825 return(OnCommand(hWnd, wParam, lParam)); 00826 00827 case WM_ACTIVATE: 00828 return(OnActivate(hWnd, wParam, lParam)); 00829 00830 case WM_PAINT: 00831 return(OnPaint(hWnd, wParam, lParam)); 00832 00833 case WM_DRAWITEM: 00834 return(OnDrawItem(hWnd, wParam, lParam)); 00835 00836 case WM_CTLCOLORSTATIC: 00837 return(OnCtlColorStatic(hWnd, wParam, lParam)); 00838 00839 case WM_MOUSEMOVE: 00840 return(OnMouseMove(hWnd, wParam, lParam)); 00841 00842 case WM_DESTROY: 00843 OnDestroy(hWnd, wParam, lParam); 00844 PostQuitMessage(0); 00845 return(0); 00846 } 00847 00848 return(DefWindowProc(hWnd, uMsg, wParam, lParam)); 00849 } 00850 00851 /* EOF */ Generated on Sun May 27 2012 04:18:09 for ReactOS by
1.7.6.1
|