CMainFrame::CMainFrame() : data_dir_path_name( 0 ) { char *path_name = NULL; // char* data_dir_path_name = 0; const int file_name_length = 20; engine_initialized = true; precis = Tenth_of_Second; geodetic_hemiFlag = NSEW; geodetic_format = DMS; leading_zeros = 0; Set_Separator(' '); m_pSplitter = new CSplitterWnd(); LOGBRUSH lb; lb.lbStyle = BS_SOLID; background_color = RGB(192,192,192); lb.lbColor = background_color; lb.lbHatch = HS_BDIAGONAL; background_brush = CreateBrushIndirect(&lb); text_color = RGB(0,0,0); long error_code = Initialize_Engine(); // Check for ellipsoid file errors if (error_code & ENGINE_ELLIPSOID_ERROR) { engine_initialized = false; AfxMessageBox("Error initializing GEOTRANS engine: Unable to locate ellipsoid data file: ellips.dat!",MB_OK | MB_ICONEXCLAMATION); } if (error_code & ENGINE_ELLIPSOID_OVERFLOW) { engine_initialized = false; AfxMessageBox("Error initializing GEOTRANS engine: Ellipsoid table is full!",MB_OK | MB_ICONEXCLAMATION); } if (error_code & ENGINE_INVALID_CODE_ERROR) { engine_initialized = false; AfxMessageBox("Error initializing GEOTRANS engine: Invalid ellipsoid code!",MB_OK | MB_ICONEXCLAMATION); } // Check for datum file errors if (error_code & ENGINE_DATUM_ERROR) { engine_initialized = false; AfxMessageBox("Error initializing GEOTRANS engine: Unable to locate datum data files: 3_param.dat, 7_param.dat!",MB_OK | MB_ICONEXCLAMATION); } if (error_code & ENGINE_DATUM_OVERFLOW) { engine_initialized = false; AfxMessageBox("Error initializing GEOTRANS engine: Datum table is full!",MB_OK | MB_ICONEXCLAMATION); } if (error_code & ENGINE_DATUM_FILE_PARSE_ERROR) { engine_initialized = false; AfxMessageBox("Error initializing GEOTRANS engine: Unable to read datum file!",MB_OK | MB_ICONEXCLAMATION); } // Check for geoid file errors if (error_code & ENGINE_GEOID_ERROR) { engine_initialized = false; AfxMessageBox("Error initializing GEOTRANS engine: Unable to locate geoid data files: egm84.grd, egm96.grd!",MB_OK | MB_ICONEXCLAMATION); } if (error_code & ENGINE_GEOID_FILE_PARSE_ERROR) { engine_initialized = false; AfxMessageBox("Error initializing GEOTRANS engine: Unable to read geoid file!",MB_OK | MB_ICONEXCLAMATION); } Set_Precision(precis); getcwd(current_dir, 256); /* Check the environment for a user provided path, else current directory; */ /* Build a File Name, including specified or default path: */ path_name = getenv( "GEOTRANS_DATA" ); if (path_name != NULL) { data_dir_path_name = new char[ strlen( path_name ) + 13 ]; strcpy( data_dir_path_name, path_name ); strcat( data_dir_path_name, "/" ); } else { data_dir_path_name = new char[ file_name_length ]; strcpy( data_dir_path_name, "../data/" ); } strcat( data_dir_path_name, "default.xml" ); defaults = new Defaults( data_dir_path_name ); createDatumPropertySheet = new CCreateDatumPropertySheet("Create Datum"); }
//------------------------------------------------------------------------------------------------ // Name: dialogEvent // Desc: Default implementation //------------------------------------------------------------------------------------------------ INT_PTR dialogEvent( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { if( uMsg == WM_CLOSE ) { EndDialog( hDlg, 0 ); DestroyWindow( hDlg ); } if( uMsg == WM_INITDIALOG ) { } switch( uMsg ) { case WM_NCPAINT: { PAINTSTRUCT ps; //HANDLE hBm = LoadImage( NULL, "evidyon-bg.bmp", IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION|LR_LOADFROMFILE ); HANDLE hBm = LoadImage( (HINSTANCE)GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION|LR_SHARED ); HDC hImgDc = CreateCompatibleDC( 0 ); HGDIOBJ oldBM = SelectObject( hImgDc, (HGDIOBJ)hBm ); BeginPaint( hDlg, &ps ); BitBlt( ps.hdc, 0, 0, 469, 469, hImgDc, 0, 0, SRCCOPY ); SelectObject( hImgDc, oldBM ); DeleteObject( hBm ); DeleteDC( hImgDc ); EndPaint( hDlg, &ps ); /* //ValidateRect( GetDlgItem( myMainWindow, 100 ), NULL ); PAINTSTRUCT ps; HDC hdc = GetWindowDC(hDlg);//GetDCEx(hWnd, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN); //HDC hdc = BeginPaint( hWnd, &ps ); //HBITMAP hBm = LoadBitmap( GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BTRLOGINWINDOW) ); HGDIOBJ oldBM = SelectObject( hImgDc, (HGDIOBJ)hBm ); BitBlt( hdc, 0, 0, 400, 300, hImgDc, 0, 0, SRCCOPY ); SelectObject( hImgDc, oldBM ); DeleteObject( hBm ) ; DeleteDC( hImgDc ); ReleaseDC( hDlg, hdc ); EndPaint( hDlg, &ps );*/ } break; case WM_LBUTTONDOWN: { // --------------------------------------------------------- // this is a common trick for easy dragging of the window. // this message fools windows telling that the user is // actually dragging the application caption bar. // --------------------------------------------------------- SendMessage(hDlg, WM_NCLBUTTONDOWN, HTCAPTION,NULL); } break; // Change the color of the dialog's background case WM_CTLCOLORDLG: { LOGBRUSH lb; lb.lbColor = SKIN_TRANSPARENT_COLOR; lb.lbHatch = 0; lb.lbStyle = BS_SOLID; return (INT_PTR)CreateBrushIndirect( &lb ); } break; } return 0; }
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; RECT rc; HBRUSH hBrush, hBrushOld; HPEN hPen, hPenOld; LOGBRUSH lgBrush; int index; static BioAPI_UUID_PTR uuid; BioAPI_RETURN bioReturn; TCHAR szUserName[100]; BioAPI_VERSION Version; BioAPI_BIR_HANDLE EnrolledTemplate, CapturedTemplate, ProcessedBir; BioAPI_INPUT_BIR birEnroll, birCapture, InputBirProcessed; BioAPI_BIR_HEADER birHeader; BioAPI_FAR MaxFAR, AchievedFAR; BioAPI_BOOL bResponse; BioAPI_BOOL bPrecedence = BioAPI_TRUE; static BioAPI_BSP_SCHEMA * CurrSchema; switch (iMsg) { case WM_PAINT : hdc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rc); lgBrush.lbStyle = BS_SOLID; lgBrush.lbColor = GetSysColor(COLOR_3DFACE); hBrush = CreateBrushIndirect(&lgBrush); hPen = CreatePen(PS_SOLID, 0, GetSysColor(COLOR_3DFACE)); hPenOld = SelectObject(hdc, hPen); hBrushOld = SelectObject(hdc, hBrush); Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom); SelectObject(hdc, hBrushOld); SelectObject(hdc, hPenOld); DeleteObject(hBrush); DeleteObject(hPen); EndPaint(hwnd, &ps); return 0; case WM_COMMAND : switch (HIWORD (wParam)) { case CBN_SELCHANGE : ReleaseBSP(&uuid); // Retrieve the index of the item selected index = SendMessage(hEnumTech, CB_GETCURSEL, 0, 0); // Retrieve a pointer to the uuid for the module CurrSchema = (BioAPI_BSP_SCHEMA *)SendMessage(hEnumTech, CB_GETITEMDATA, index, 0); uuid = (BioAPI_UUID *)malloc(sizeof(BioAPI_UUID)); if(uuid == NULL) { MessageBox(hwnd, TEXT("Unable to allocate memory to load the module identifier"), TEXT("BioAPI Sample"), MB_OK); return 0; } BioAPI_CopyUuid(uuid, CurrSchema->ModuleId); bioReturn = BioAPI_ModuleLoad(uuid, 0, NULL/*(BioAPI_ModuleEventHandler)BiometricEventHandler*/, 0); if(BioAPI_OK != bioReturn) { PrintErrorCode(bioReturn); free(uuid); uuid = NULL; return 0; } // wsprintf(szCurrHandle, TEXT("Current Handle: 0x%X"), hBtCurrent); // SetWindowText(hCurrHbt, szCurrHandle); Version.Major = BioAPI_MAJOR; Version.Minor = BioAPI_MINOR; bioReturn = BioAPI_ModuleAttach(uuid, &Version, &BioAPIWinMemoryFuncs, 0, 0,0,0, NULL, 0, NULL, &gModuleHandle); if(BioAPI_OK != bioReturn) { PrintErrorCode(bioReturn); BioAPI_ModuleUnload (uuid, NULL, 0); free(uuid); uuid = NULL; return 0; } break; case BN_CLICKED: switch (LOWORD (wParam)) { case IDOK : ReleaseBSP(&uuid); EndDialog(hwnd, 0); PostQuitMessage(0); break; case IDC_ENROLL : if(GetWindowText(hUserId, szUserName, 100)==0) MessageBox(hwnd, TEXT("Please specify a user id"), TEXT("Bad User Id"), MB_OK); else { bioReturn = BioAPI_Enroll(gModuleHandle, BioAPI_PURPOSE_ENROLL_FOR_VERIFICATION_ONLY, NULL, &EnrolledTemplate, NULL, -1, NULL); if(bioReturn != BioAPI_OK) { PrintErrorCode(bioReturn); return 0; } OutputToFile(szUserName, EnrolledTemplate); } break; case IDC_VERIFY : if(GetWindowText(hUserId, szUserName, 100)==0) MessageBox(hwnd, TEXT("Please specify a user id"), TEXT("Bad User Id"), MB_OK); else { if(InputFromFile(szUserName, &birEnroll) != BioAPI_OK) { MessageBox(hwnd, TEXT("User not enrolled"), TEXT("Bad User Id"), MB_OK); return 0; } // See if the BSP supports BioAPI_VerifyMatch by checking // the operations mask if(CurrSchema->Operations & BioAPI_VERIFYMATCH) { if((bioReturn = BioAPI_Capture(gModuleHandle, BioAPI_PURPOSE_VERIFY, &CapturedTemplate, -1, NULL)) != BioAPI_OK) { PrintErrorCode(bioReturn); GlobalFree(birEnroll.InputBIR.BIR); return 0; } if((bioReturn = BioAPI_GetHeaderFromHandle(gModuleHandle, CapturedTemplate, &birHeader)) != BioAPI_OK) { PrintErrorCode(bioReturn); GlobalFree(birEnroll.InputBIR.BIR); return 0; } if(birHeader.Type == BioAPI_BIR_DATA_TYPE_INTERMEDIATE) { birCapture.Form = BioAPI_BIR_HANDLE_INPUT; birCapture.InputBIR.BIRinBSP = &CapturedTemplate; if((bioReturn = BioAPI_Process(gModuleHandle, &birCapture, &ProcessedBir)) != BioAPI_OK) { PrintErrorCode(bioReturn); GlobalFree(birEnroll.InputBIR.BIR); return 0; } MaxFAR = 1; InputBirProcessed.Form = BioAPI_BIR_HANDLE_INPUT; InputBirProcessed.InputBIR.BIRinBSP = &ProcessedBir; } else { MaxFAR = 1; InputBirProcessed.Form = BioAPI_BIR_HANDLE_INPUT; InputBirProcessed.InputBIR.BIRinBSP = &CapturedTemplate; } bioReturn = BioAPI_VerifyMatch(gModuleHandle, &MaxFAR, NULL, &bPrecedence, &InputBirProcessed, &birEnroll, NULL, &bResponse, &AchievedFAR, NULL, NULL); } else // We simply call BioAPI_Verify { MaxFAR = 1; bioReturn = BioAPI_Verify(gModuleHandle, &MaxFAR, NULL, &bPrecedence, &birEnroll, NULL, &bResponse, &AchievedFAR, NULL, NULL, -1, NULL); } GlobalFree(birEnroll.InputBIR.BIR); if(bioReturn != BioAPI_OK) { PrintErrorCode(bioReturn); return 0; } if(bResponse == TRUE) MessageBox(hwnd, TEXT("Match"), TEXT("BioAPI"), MB_OK); else MessageBox(hwnd, TEXT("No Match"), TEXT("BioAPI"), MB_OK); } break; } break; } return 0 ; case WM_CLOSE : ReleaseBSP(&uuid); EndDialog(hwnd, 0); PostQuitMessage(0); return 0; case WM_DESTROY : ReleaseBSP(&uuid); EndDialog(hwnd, 0); PostQuitMessage(0); return 0 ; } return DefWindowProc (hwnd, iMsg, wParam, lParam) ; }
HBRUSH EmfPaintEngine::convertBrush(const QBrush& brush) { LOGBRUSH lbrush = {BS_NULL, 0, 0}; if (!brush.color().alpha()) return CreateBrushIndirect( &lbrush ); if (brush.color().alpha() < 255){//semi-transparent brush color qWarning ("Semi-transparent brushes are not supported by EmfEngine."); #ifdef Q_WS_WIN QPixmap pix(4, 4); pix.fill(Qt::white); QPainter p; p.begin(&pix); p.setPen(QPen(Qt::NoPen)); p.setBrush(brush); p.drawRect(QRect(0, 0, 4, 4)); p.end(); HBITMAP hBmp = pix.toWinHBITMAP(); HBRUSH wbrush = CreatePatternBrush(hBmp); DeleteObject(hBmp); return wbrush; #endif } LONG lbHatch = HS_HORIZONTAL; UINT lbStyle = BS_HATCHED; switch(brush.style()){ case Qt::NoBrush: lbStyle = BS_NULL; break; case Qt::SolidPattern: lbStyle = BS_SOLID; break; case Qt::Dense1Pattern: case Qt::Dense2Pattern: case Qt::Dense3Pattern: case Qt::Dense4Pattern: case Qt::Dense5Pattern: case Qt::Dense6Pattern: case Qt::Dense7Pattern: { #ifdef Q_WS_WIN QPixmap pix(4, 4); pix.fill(Qt::white); QPainter p; p.begin(&pix); p.setPen(QPen(Qt::NoPen)); p.setBrush(brush); p.drawRect(QRect(0, 0, 4, 4)); p.end(); HBITMAP hbm = pix.toWinHBITMAP(); HBRUSH wbrush = CreatePatternBrush(hbm); DeleteObject(hbm); return wbrush; #endif } break; case Qt::HorPattern: break; case Qt::VerPattern: lbHatch = HS_VERTICAL; break; case Qt::CrossPattern: lbHatch = HS_CROSS; break; case Qt::BDiagPattern: lbHatch = HS_BDIAGONAL; break; case Qt::FDiagPattern: lbHatch = HS_FDIAGONAL; break; case Qt::DiagCrossPattern: lbHatch = HS_DIAGCROSS; break; case Qt::LinearGradientPattern: { qWarning("EmfEngine: Qt::LinearGradientPattern is not supported."); return CreateBrushIndirect( &lbrush ); } break; case Qt::ConicalGradientPattern: { qWarning("EmfEngine: Qt::ConicalGradientPattern is not supported."); return CreateBrushIndirect( &lbrush ); } break; case Qt::RadialGradientPattern: { qWarning("EmfEngine: Qt::RadialGradientPattern is not supported."); return CreateBrushIndirect( &lbrush ); } case Qt::TexturePattern: #ifdef Q_WS_WIN { HBITMAP hbm = brush.texture().toWinHBITMAP(); HBRUSH wbrush = CreatePatternBrush(hbm); DeleteObject(hbm); return wbrush; } #endif break; default: lbStyle = BS_SOLID; break; } LOGBRUSH logbrush = {lbStyle, RGB(brush.color().red(), brush.color().green(), brush.color().blue()), lbHatch}; return CreateBrushIndirect( &logbrush ); }
// // 函数: WndProc(HWND, UINT, WPARAM, LPARAM) // // 目的: 处理主窗口的消息。 // // WM_COMMAND - 处理应用程序菜单 // WM_PAINT - 绘制主窗口 // WM_DESTROY - 发送退出消息并返回 // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; LOGBRUSH brush; brush.lbStyle = BS_NULL; HBRUSH hBrush = CreateBrushIndirect(&brush); LOGPEN pen; POINT penWidth; penWidth.x = 2; penWidth.y = 2; int color[7][3] = { { 254, 67, 101 }, { 217, 104, 49 }, { 250, 227, 113 }, { 131, 175, 155 }, { 69, 137, 148 }, { 1, 77, 103 }, { 89, 61, 67 } }; pen.lopnColor = RGB(color[rown][0], color[rown][1], color[rown][2]); timess = timess + 1; if (timess == TIMESS) { rown = rown + 1; timess = 0; } if (rown == 6) rown = -0; pen.lopnStyle = PS_SOLID; pen.lopnWidth = penWidth; HPEN hPen = CreatePenIndirect(&pen); switch (message) { case WM_TRAY: switch (lParam) { case WM_RBUTTONDOWN: { //获取鼠标坐标 POINT pt; GetCursorPos(&pt); //解决在菜单外单击左键菜单不消失的问题 SetForegroundWindow(hWnd); //使菜单某项变灰 //EnableMenuItem(hMenu, ID_SHOW, MF_GRAYED); //显示并获取选中的菜单 int cmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, NULL, hWnd, NULL); if (cmd == ID_SHOW) MessageBox(hWnd, L"Win32 API 实现系统托盘程序", L"托盘程序", MB_OK); if (cmd == ID_EXIT) PostMessage(hWnd, WM_DESTROY, NULL, NULL); } break; case WM_LBUTTONDOWN: MessageBox(hWnd, L"Win32 API 实现系统托盘程序", L"托盘程序", MB_OK); break; case WM_LBUTTONDBLCLK: break; } break; case WM_TIMER: ShowTrayMsg(); KillTimer(hWnd, wParam); break; case WM_COPYDATA: if (wParam == -1 && lParam == -1) { GetScreenCapture(); ShowWindow(hWnd, SW_SHOW); UpdateWindow(hWnd); } case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // 分析菜单选择: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_CREATE: //GetScreenCapture(); break; case WM_PAINT: { hdc = BeginPaint(hWnd, &ps); HDC memDc = CreateCompatibleDC(hdc); HBITMAP bmp = CreateCompatibleBitmap(hdc, screenW, screenH); SelectObject(memDc, bmp); BitBlt(memDc, 0, 0, screenW, screenH, g_grayMemDc, 0, 0, SRCCOPY); SelectObject(memDc, hBrush); SelectObject(memDc, hPen); if (isDrawing || isSelect) { BitBlt(memDc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, g_srcMemDc, rect.left, rect.top, SRCCOPY); Rectangle(memDc, rect.left, rect.top, rect.right, rect.bottom); } BitBlt(hdc, 0, 0, screenW, screenH, memDc, 0, 0, SRCCOPY); DeleteObject(bmp); DeleteObject(memDc); EndPaint(hWnd, &ps); } break; case WM_LBUTTONDOWN: { if (!isSelect) { POINT pt; GetCursorPos(&pt); rect.left = pt.x; rect.top = pt.y; rect.right = pt.x; rect.bottom = pt.y; isDrawing = true; InvalidateRgn(hWnd, 0, false); } } break; case WM_LBUTTONUP: { if (isDrawing && !isSelect) { isDrawing = false; POINT pt; GetCursorPos(&pt); rect.right = pt.x; rect.bottom = pt.y; isSelect = true; InvalidateRgn(hWnd, 0, false); } } break; case WM_MOUSEMOVE: { if (isDrawing&& !isSelect) { POINT pt; GetCursorPos(&pt); rect.right = pt.x; rect.bottom = pt.y; InvalidateRgn(hWnd, 0, false); } } break; case WM_LBUTTONDBLCLK: { if (isSelect) { WriteDatatoClipBoard(); InvalidateRgn(hWnd, 0, false); ShowWindow(hWnd, SW_HIDE); //ShowWindow(hWnd, SW_MINIMIZE); TCHAR MyDir[_MAX_PATH]; SHGetSpecialFolderPath(hWnd, MyDir, CSIDL_DESKTOP, 0); //获取特殊路径,获取桌面路径 CString str; str.Format(_T("%s"), MyDir); CString depart = "\\"; CString lkuohao = "("; CString rkuohao = ")"; CString name = SHOT_NAME; CString cstype = SHOT_TYPE; //cstring to char* CString strPath = str + depart + name + cstype; //char *path = (LPSTR)(LPCTSTR)cstr; //CString strPath = L"C:\\Users\\Wayne\\Desktop\\2015年最新软件进展\\call_log.csv"; int nLength = strPath.GetLength(); int nBytes = WideCharToMultiByte(CP_ACP, 0, strPath, nLength, NULL, 0, NULL, NULL); char* VoicePath = new char[nBytes + 1]; memset(VoicePath, 0, nLength + 1); WideCharToMultiByte(CP_OEMCP, 0, strPath, nLength, VoicePath, nBytes, NULL, NULL); VoicePath[nBytes] = 0; //strPath *VoicePath int woc = 2; CString woca; CString cstrn = strPath; while (_access(VoicePath, 0) == 0) { woca.Format(_T("%d"), woc); cstrn = strPath + lkuohao + woca + rkuohao + cstype; //判断有没有~ int n2Length = cstrn.GetLength(); int n2Bytes = WideCharToMultiByte(CP_ACP, 0, cstrn, n2Length, NULL, 0, NULL, NULL); VoicePath = new char[n2Bytes + 1]; memset(VoicePath, 0, n2Length + 1); WideCharToMultiByte(CP_OEMCP, 0, cstrn, n2Length, VoicePath, n2Bytes, NULL, NULL); VoicePath[n2Bytes] = 0; woc++; } SaveBmp(hBmp, cstrn); //使用下面的函数 } isSelect = false; } break; case WM_DESTROY: {//窗口销毁时删除托盘 Shell_NotifyIcon(NIM_DELETE, &nid); UNINSPROC uninstproc; uninstproc = (UNINSPROC)GetProcAddress(m_hDll, "UnInstallHook"); BOOL bResult = uninstproc(); ::FreeLibrary(m_hDll); m_hDll = NULL; PostQuitMessage(0); break; } default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
static void test_pattern_brush(void) { char buffer[sizeof(BITMAPINFOHEADER) + 2 * sizeof(RGBQUAD) + 32 * 32 / 8]; BITMAPINFO *info = (BITMAPINFO *)buffer; HBRUSH brush; HBITMAP bitmap; LOGBRUSH br; INT ret; void *bits; DIBSECTION dib; HGLOBAL mem; bitmap = CreateBitmap( 20, 20, 1, 1, NULL ); ok( bitmap != NULL, "CreateBitmap failed\n" ); brush = CreatePatternBrush( bitmap ); ok( brush != NULL, "CreatePatternBrush failed\n" ); memset( &br, 0x55, sizeof(br) ); ret = GetObjectW( brush, sizeof(br), &br ); ok( ret == sizeof(br), "wrong size %u\n", ret ); ok( br.lbStyle == BS_PATTERN, "wrong style %u\n", br.lbStyle ); ok( br.lbColor == 0, "wrong color %u\n", br.lbColor ); ok( (HBITMAP)br.lbHatch == bitmap, "wrong handle %p/%p\n", (HBITMAP)br.lbHatch, bitmap ); DeleteObject( brush ); br.lbStyle = BS_PATTERN8X8; br.lbColor = 0x12345; br.lbHatch = (ULONG_PTR)bitmap; brush = CreateBrushIndirect( &br ); ok( brush != NULL, "CreatePatternBrush failed\n" ); memset( &br, 0x55, sizeof(br) ); ret = GetObjectW( brush, sizeof(br), &br ); ok( ret == sizeof(br), "wrong size %u\n", ret ); ok( br.lbStyle == BS_PATTERN, "wrong style %u\n", br.lbStyle ); ok( br.lbColor == 0, "wrong color %u\n", br.lbColor ); ok( (HBITMAP)br.lbHatch == bitmap, "wrong handle %p/%p\n", (HBITMAP)br.lbHatch, bitmap ); ret = GetObjectW( bitmap, sizeof(dib), &dib ); ok( ret == sizeof(dib.dsBm), "wrong size %u\n", ret ); DeleteObject( bitmap ); ret = GetObjectW( bitmap, sizeof(dib), &dib ); ok( ret == 0, "wrong size %u\n", ret ); DeleteObject( brush ); memset( info, 0, sizeof(buffer) ); info->bmiHeader.biSize = sizeof(info->bmiHeader); info->bmiHeader.biHeight = 32; info->bmiHeader.biWidth = 32; info->bmiHeader.biBitCount = 1; info->bmiHeader.biPlanes = 1; info->bmiHeader.biCompression = BI_RGB; bitmap = CreateDIBSection( 0, info, DIB_RGB_COLORS, (void**)&bits, NULL, 0 ); ok( bitmap != NULL, "CreateDIBSection failed\n" ); /* MSDN says a DIB section is not allowed, but it works fine */ brush = CreatePatternBrush( bitmap ); ok( brush != NULL, "CreatePatternBrush failed\n" ); memset( &br, 0x55, sizeof(br) ); ret = GetObjectW( brush, sizeof(br), &br ); ok( ret == sizeof(br), "wrong size %u\n", ret ); ok( br.lbStyle == BS_PATTERN, "wrong style %u\n", br.lbStyle ); ok( br.lbColor == 0, "wrong color %u\n", br.lbColor ); ok( (HBITMAP)br.lbHatch == bitmap, "wrong handle %p/%p\n", (HBITMAP)br.lbHatch, bitmap ); ret = GetObjectW( bitmap, sizeof(dib), &dib ); ok( ret == sizeof(dib), "wrong size %u\n", ret ); DeleteObject( brush ); DeleteObject( bitmap ); brush = CreateDIBPatternBrushPt( info, DIB_RGB_COLORS ); ok( brush != NULL, "CreatePatternBrush failed\n" ); memset( &br, 0x55, sizeof(br) ); ret = GetObjectW( brush, sizeof(br), &br ); ok( ret == sizeof(br), "wrong size %u\n", ret ); ok( br.lbStyle == BS_DIBPATTERN, "wrong style %u\n", br.lbStyle ); ok( br.lbColor == 0, "wrong color %u\n", br.lbColor ); ok( (BITMAPINFO *)br.lbHatch == info || broken(!br.lbHatch), /* nt4 */ "wrong handle %p/%p\n", (BITMAPINFO *)br.lbHatch, info ); DeleteObject( brush ); br.lbStyle = BS_DIBPATTERNPT; br.lbColor = DIB_PAL_COLORS; br.lbHatch = (ULONG_PTR)info; brush = CreateBrushIndirect( &br ); ok( brush != NULL, "CreatePatternBrush failed\n" ); memset( &br, 0x55, sizeof(br) ); ret = GetObjectW( brush, sizeof(br), &br ); ok( ret == sizeof(br), "wrong size %u\n", ret ); ok( br.lbStyle == BS_DIBPATTERN, "wrong style %u\n", br.lbStyle ); ok( br.lbColor == 0, "wrong color %u\n", br.lbColor ); ok( (BITMAPINFO *)br.lbHatch == info || broken(!br.lbHatch), /* nt4 */ "wrong handle %p/%p\n", (BITMAPINFO *)br.lbHatch, info ); mem = GlobalAlloc( GMEM_MOVEABLE, sizeof(buffer) ); memcpy( GlobalLock( mem ), buffer, sizeof(buffer) ); br.lbStyle = BS_DIBPATTERN; br.lbColor = DIB_PAL_COLORS; br.lbHatch = (ULONG_PTR)mem; brush = CreateBrushIndirect( &br ); ok( brush != NULL, "CreatePatternBrush failed\n" ); memset( &br, 0x55, sizeof(br) ); ret = GetObjectW( brush, sizeof(br), &br ); ok( ret == sizeof(br), "wrong size %u\n", ret ); ok( br.lbStyle == BS_DIBPATTERN, "wrong style %u\n", br.lbStyle ); ok( br.lbColor == 0, "wrong color %u\n", br.lbColor ); ok( (HGLOBAL)br.lbHatch != mem, "wrong handle %p/%p\n", (HGLOBAL)br.lbHatch, mem ); bits = GlobalLock( mem ); ok( (HGLOBAL)br.lbHatch == bits || broken(!br.lbHatch), /* nt4 */ "wrong handle %p/%p\n", (HGLOBAL)br.lbHatch, bits ); ret = GlobalFlags( mem ); ok( ret == 2, "wrong flags %x\n", ret ); DeleteObject( brush ); ret = GlobalFlags( mem ); ok( ret == 2, "wrong flags %x\n", ret ); brush = CreateDIBPatternBrushPt( info, DIB_PAL_COLORS ); ok( brush != 0, "CreateDIBPatternBrushPt failed\n" ); DeleteObject( brush ); brush = CreateDIBPatternBrushPt( info, DIB_PAL_COLORS + 1 ); ok( brush != 0, "CreateDIBPatternBrushPt failed\n" ); DeleteObject( brush ); brush = CreateDIBPatternBrushPt( info, DIB_PAL_COLORS + 2 ); ok( !brush, "CreateDIBPatternBrushPt succeeded\n" ); brush = CreateDIBPatternBrushPt( info, DIB_PAL_COLORS + 3 ); ok( !brush, "CreateDIBPatternBrushPt succeeded\n" ); info->bmiHeader.biBitCount = 8; info->bmiHeader.biCompression = BI_RLE8; brush = CreateDIBPatternBrushPt( info, DIB_RGB_COLORS ); ok( !brush, "CreateDIBPatternBrushPt succeeded\n" ); info->bmiHeader.biBitCount = 4; info->bmiHeader.biCompression = BI_RLE4; brush = CreateDIBPatternBrushPt( info, DIB_RGB_COLORS ); ok( !brush, "CreateDIBPatternBrushPt succeeded\n" ); br.lbStyle = BS_DIBPATTERN8X8; br.lbColor = DIB_RGB_COLORS; br.lbHatch = (ULONG_PTR)mem; brush = CreateBrushIndirect( &br ); ok( !brush, "CreatePatternBrush succeeded\n" ); br.lbStyle = BS_MONOPATTERN; br.lbColor = DIB_RGB_COLORS; br.lbHatch = (ULONG_PTR)mem; brush = CreateBrushIndirect( &br ); ok( !brush, "CreatePatternBrush succeeded\n" ); br.lbStyle = BS_INDEXED; br.lbColor = DIB_RGB_COLORS; br.lbHatch = (ULONG_PTR)mem; brush = CreateBrushIndirect( &br ); ok( !brush, "CreatePatternBrush succeeded\n" ); GlobalFree( mem ); }
//Yeah this truly turned into a mess with the latest additions.. but it sure looks nice ;) void CtrlRegisterList::onPaint(WPARAM wParam, LPARAM lParam) { if (!cpu) return; GetClientRect(wnd, &rect); PAINTSTRUCT ps; HDC hdc; hdc = BeginPaint(wnd, &ps); // TODO: Add any drawing code here... int width = rect.right; //numRows=(numRows&(~1)) + 1; SetBkMode(hdc, TRANSPARENT); DWORD bgColor = 0xffffff; HPEN nullPen=CreatePen(0,0,bgColor); HPEN currentPen=CreatePen(0,0,0); HPEN selPen=CreatePen(0,0,0x808080); LOGBRUSH lbr; lbr.lbHatch=0; lbr.lbStyle=0; lbr.lbColor=bgColor; HBRUSH nullBrush=CreateBrushIndirect(&lbr); lbr.lbColor=0xFFEfE8; HBRUSH currentBrush=CreateBrushIndirect(&lbr); lbr.lbColor=0x70FF70; HBRUSH pcBrush=CreateBrushIndirect(&lbr); HPEN oldPen=(HPEN)SelectObject(hdc,nullPen); HBRUSH oldBrush=(HBRUSH)SelectObject(hdc,nullBrush); HFONT oldFont = (HFONT)SelectObject(hdc,(HGDIOBJ)font); // HICON breakPoint = (HICON)LoadIcon(GetModuleHandle(0),(LPCSTR)IDI_STOP); // HICON breakPointDisable = (HICON)LoadIcon(GetModuleHandle(0),(LPCSTR)IDI_STOPDISABLE); int nc = cpu->GetNumCategories(); for (int i=0; i<nc; i++) { SelectObject(hdc,i==category?currentPen:nullPen); SelectObject(hdc,i==category?pcBrush:nullBrush); Rectangle(hdc,width*i/nc,0,width*(i+1)/nc,rowHeight); const char *name = cpu->GetCategoryName(i); TextOutA(hdc,width*i/nc,1,name,(int)strlen(name)); } int numRows=rect.bottom/rowHeight; for (int i=0; i<numRows; i++) { int rowY1 = rowHeight*(i+1); int rowY2 = rowHeight*(i+2); lbr.lbColor = i==selection?0xffeee0:0xffffff; SelectObject(hdc,currentBrush); SelectObject(hdc,nullPen); Rectangle(hdc,0,rowY1,16,rowY2); if (selecting && i == selection) SelectObject(hdc,selPen); else SelectObject(hdc,nullPen); HBRUSH mojsBrush=CreateBrushIndirect(&lbr); SelectObject(hdc,mojsBrush); //else // SelectObject(hdc,i==0 ? currentBrush : nullBrush); Rectangle(hdc,16,rowY1,width,rowY2); // Check for any changes in the registers. if (lastPC != cpu->GetPC()) { for (int j = 0, n = cpu->GetNumRegsInCategory(0); j < n; ++j) { u32 v = cpu->GetRegValue(0, j); changedCat0Regs[j] = v != lastCat0Values[j]; lastCat0Values[j] = v; } changedCat0Regs[REGISTER_PC] = cpu->GetPC() != lastCat0Values[REGISTER_PC]; lastCat0Values[REGISTER_PC] = cpu->GetPC(); changedCat0Regs[REGISTER_HI] = cpu->GetHi() != lastCat0Values[REGISTER_HI]; lastCat0Values[REGISTER_HI] = cpu->GetHi(); changedCat0Regs[REGISTER_LO] = cpu->GetLo() != lastCat0Values[REGISTER_LO]; lastCat0Values[REGISTER_LO] = cpu->GetLo(); lastPC = cpu->GetPC(); } SelectObject(hdc,currentBrush); DeleteObject(mojsBrush); if (i<cpu->GetNumRegsInCategory(category)) { char temp[256]; int temp_len = sprintf(temp,"%s",cpu->GetRegName(category,i)); SetTextColor(hdc,0x600000); TextOutA(hdc,17,rowY1,temp,temp_len); SetTextColor(hdc,0x000000); cpu->PrintRegValue(category,i,temp); if (category == 0 && changedCat0Regs[i]) SetTextColor(hdc, 0x0000FF); else SetTextColor(hdc,0x004000); TextOutA(hdc,77,rowY1,temp,(int)strlen(temp)); } else if (category == 0 && i < REGISTERS_END) { char temp[256]; int len; u32 value; switch (i) { case REGISTER_PC: value = cpu->GetPC(); len = sprintf(temp,"pc"); break; case REGISTER_HI: value = cpu->GetHi(); len = sprintf(temp,"hi"); break; case REGISTER_LO: value = cpu->GetLo(); len = sprintf(temp,"lo"); break; default: temp[0] = '\0'; break; } SetTextColor(hdc,0x600000); TextOutA(hdc,17,rowY1,temp,len); len = sprintf(temp,"%08X",value); if (changedCat0Regs[i]) SetTextColor(hdc, 0x0000FF); else SetTextColor(hdc,0x004000); TextOutA(hdc,77,rowY1,temp,(int)strlen(temp)); } } SelectObject(hdc,oldFont); SelectObject(hdc,oldPen); SelectObject(hdc,oldBrush); DeleteObject(nullPen); DeleteObject(currentPen); DeleteObject(selPen); DeleteObject(nullBrush); DeleteObject(pcBrush); DeleteObject(currentBrush); // DestroyIcon(breakPoint); // DestroyIcon(breakPointDisable); EndPaint(wnd, &ps); }
//Yeah this truly turned into a mess with the latest additions.. but it sure looks nice ;) void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) { GetClientRect(wnd, &rect); PAINTSTRUCT ps; HDC hdc; hdc = BeginPaint(wnd, &ps); int width = rect.right; int numRows=(rect.bottom/rowHeight)/2+1; SetBkMode(hdc, TRANSPARENT); HPEN nullPen=CreatePen(0,0,0xFFFFFF); HPEN currentPen=CreatePen(0,0,0); HPEN selPen=CreatePen(0,0,0x808080); LOGBRUSH lbr; lbr.lbHatch=0; lbr.lbStyle=0; lbr.lbColor=0xFFFFFF; HBRUSH nullBrush=CreateBrushIndirect(&lbr); lbr.lbColor=0xFFEfE8; HBRUSH currentBrush=CreateBrushIndirect(&lbr); lbr.lbColor=0x70FF70; HBRUSH pcBrush=CreateBrushIndirect(&lbr); HPEN oldPen=(HPEN)SelectObject(hdc,nullPen); HBRUSH oldBrush=(HBRUSH)SelectObject(hdc,nullBrush); HFONT oldFont = (HFONT)SelectObject(hdc,(HGDIOBJ)font); int i; for (i=-numRows; i<=numRows; i++) { unsigned int address=curAddress + i*align; int rowY1 = rect.bottom/2 + rowHeight*i - rowHeight/2; int rowY2 = rect.bottom/2 + rowHeight*i + rowHeight/2; wchar temp[256]; swprintf(temp,L"%08x",address); //SelectObject(hdc,currentBrush); Rectangle(hdc,0,rowY1,16,rowY2); if(selecting && address == (u32)selection) SelectObject(hdc,selPen); else SelectObject(hdc,i==0 ? currentPen : nullPen); Rectangle(hdc,16,rowY1,width,rowY2); SelectObject(hdc,nullBrush); SetTextColor(hdc,0x600000); TextOut(hdc,17,rowY1,temp,(int)wcslen(temp)); SetTextColor(hdc,0x000000); switch(mode) { case MV_NORMAL: swprintf(temp, L"%08X %08X %08X %08X", ReadMem32((address+0)), ReadMem32((address+4)), ReadMem32((address+8)), ReadMem32((address+12))); TextOut(hdc,90,rowY1,temp,(int)wcslen(temp)); SetTextColor(hdc,0x0033BB22); ((u32*)temp)[0] = ReadMem32(address); ((u32*)temp)[1] = ReadMem32(address+4); ((u32*)temp)[2] = ReadMem32(address+8); ((u32*)temp)[3] = ReadMem32(address+12); ((u32*)temp)[4] = 0x00000000; TextOut(hdc,420,rowY1,temp,(int)wcslen(temp)); break; case MV_SYMBOLS: SetTextColor(hdc,0x0000FF); int fn = address&3;//Debugger_GetSymbolNum(address); swprintf(temp,L"MV_SYMBOLS !!!"); // sprintf(temp, "%s (0x%x b)", Debugger_GetSymbolName(fn),Debugger_GetSymbolSize(fn)); TextOut(hdc,200,rowY1,temp,(int)wcslen(temp)); SetTextColor(hdc,0x0000000); UINT value = 0xBADC0D3;//ReadMem(address,4);//CMemory::ReadUnchecked_U32(address); swprintf(temp, L"%08x", value ); // sprintf(temp, "%08x [%s]", value, Debugger_GetSymbolName(Debugger_GetSymbolNum(value))); TextOut(hdc,70,rowY1,temp,(int)wcslen(temp)); break; } } SelectObject(hdc,oldFont); SelectObject(hdc,oldPen); SelectObject(hdc,oldBrush); DeleteObject(nullPen); DeleteObject(currentPen); DeleteObject(selPen); DeleteObject(nullBrush); DeleteObject(pcBrush); DeleteObject(currentBrush); EndPaint(wnd, &ps); }
STDMETHODIMP CShellExt::Extract(LPCTSTR pszFile, UINT nIconIndex, HICON * phiconLarge, HICON * phiconSmall, UINT nIconSize) { WORD sizeSmall = HIWORD(nIconSize); WORD sizeLarge = LOWORD(nIconSize); ICONINFO iconinfo; BOOL res; HRESULT hrSmall = S_OK, hrLarge = S_OK; if (phiconSmall) hrSmall = LoadShellIcon(sizeSmall, sizeSmall, phiconSmall); if (phiconLarge) hrLarge = LoadShellIcon(sizeLarge, sizeLarge, phiconLarge); if (FAILED(hrSmall) || FAILED(hrLarge)) { InvalidateIcon(phiconSmall, phiconLarge); return S_FALSE; } if (!m_isDynamic || !phiconLarge) //No modifications required return S_OK; HDC dcEditColor, dcEditMask; HGDIOBJ oldBitmapColor, oldBitmapMask, oldFontColor; HFONT font; HBRUSH brush; res = GetIconInfo(*phiconLarge, &iconinfo); if (!res) return S_OK; //abort, the icon is still valid res = DestroyIcon(*phiconLarge); if (!res) return S_OK; else *phiconLarge = NULL; dcEditColor = CreateCompatibleDC(GetDC(0)); dcEditMask = CreateCompatibleDC(GetDC(0)); oldBitmapColor = SelectObject(dcEditColor, iconinfo.hbmColor); oldBitmapMask = SelectObject(dcEditMask, iconinfo.hbmMask); LONG calSize = (LONG)(sizeLarge*2/5); LOGFONT lf = {0}; lf.lfHeight = std::min(calSize, (LONG)15); //this is in pixels. Make no larger than 15 pixels (but smaller is allowed for small icons) lf.lfWeight = FW_NORMAL; lf.lfCharSet = DEFAULT_CHARSET; lstrcpyn(lf.lfFaceName, TEXT("Bitstream Vera Sans Mono"), LF_FACESIZE); LOGBRUSH lbrush; lbrush.lbStyle = BS_SOLID; lbrush.lbHatch = 0; RECT rect = {0}; COLORREF backGround = RGB(1, 1, 1); COLORREF textColor = RGB(255,255,255); //Grab the topleft pixel as the background color COLORREF maskBack = GetPixel(dcEditColor, 0, 0); if (backGround == maskBack) backGround++; //add one, shouldn't be very visible font = CreateFontIndirect(&lf); lbrush.lbColor = backGround; brush = CreateBrushIndirect(&lbrush); oldFontColor = SelectObject(dcEditColor, font); SetBkMode(dcEditColor, TRANSPARENT); //dont clear background when drawing text (doesnt change much, colors are the same) SetBkColor(dcEditColor, backGround); SetTextColor(dcEditColor, textColor); SIZE stringSize; GetTextExtentPoint32(dcEditColor, m_szFilePath, m_nameLength, &stringSize); stringSize.cx = std::min(stringSize.cx, (LONG)sizeLarge-2); stringSize.cy = std::min(stringSize.cy, (LONG)sizeLarge-2); rect.top = sizeLarge - stringSize.cy - 2; rect.left = sizeLarge - stringSize.cx - 1; rect.bottom = sizeLarge; rect.right = sizeLarge-1; FillRect(dcEditColor, &rect, brush); FillRect(dcEditMask, &rect, brush); rect.top += 1; rect.left -= 1; rect.bottom -= 1; rect.right += 1; FillRect(dcEditColor, &rect, brush); FillRect(dcEditMask, &rect, brush); rect.left += 1; DrawText(dcEditColor, m_szFilePath, m_nameLength, &rect, DT_BOTTOM|DT_SINGLELINE|DT_LEFT); SetBkColor(dcEditColor, maskBack); //BitBlt(dcEditMask, 0, 0, sizeLarge, sizeLarge, dcEditColor, 0, 0, SRCCOPY); SelectObject(dcEditColor, oldFontColor); SelectObject(dcEditColor, oldBitmapColor); SelectObject(dcEditMask, oldBitmapMask); DeleteDC(dcEditColor); DeleteDC(dcEditMask); DeleteBrush(brush); *phiconLarge = CreateIconIndirect(&iconinfo); res = DeleteBitmap(iconinfo.hbmColor); res = DeleteBitmap(iconinfo.hbmMask); if (*phiconLarge == NULL) { InvalidateIcon(phiconSmall, phiconLarge); return S_FALSE; } return S_OK; }
// component: int Wview::dispatch(string message){ #define clean \ delete token; \ return 0; tokenizer * token = new stringtokenizer(&message); if (token->getparam("message") == "paint"){ if (onpaint) (*onpaint)(this, message); Wform * parent = dynamic_cast < Wform * >(this->parent); if (parent){ HWND hwnd = parent->gethandle(); RECT rect; rect.left = position.first; rect.top = position.second; rect.right = rect.left + size.first; rect.bottom = rect.top + size.second; InvalidateRect(hwnd, &rect, false); PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); HDC hcdc = CreateCompatibleDC(hdc); HDC backbuffer = CreateCompatibleDC(hdc); HBITMAP buffer = CreateCompatibleBitmap(hdc, size.first, size.second); SelectObject(backbuffer, buffer); HBRUSH hbrush; HPEN hpen; LOGBRUSH brush; for (list < string >::iterator iter = drawqueue.begin(); iter != drawqueue.end(); ++iter){ string next = *iter; string buflog = "Wguicore--Wview::dispatch(paint)::debug: primitive is: " + next + "\n"; new logger(10, buflog.c_str()); tokenizer * primitive = new stringtokenizer(&next); string ptype = primitive->getparam("primitive"); int x = primitive->getparam("x", 0); int y = primitive->getparam("y", 0); int w = primitive->getparam("w", 0); int h = primitive->getparam("h", 0); int r = primitive->getparam("r", 0); int cr = primitive->getparam("rcolor", 0); int cg = primitive->getparam("gcolor", 0); int cb = primitive->getparam("bcolor", 0); int th = primitive->getparam("thickness", 0); if (th == tokenizer::unknowint) th = 0; if (cr == tokenizer::unknowint) cr = 0; if (cg == tokenizer::unknowint) cg = 0; if (cb == tokenizer::unknowint) cb = 0; brush.lbStyle = BS_SOLID; brush.lbColor = RGB(cr, cg, cb); hbrush = CreateBrushIndirect(&brush); if (ptype != "bits" && ptype != "pixel") SelectObject(backbuffer, hbrush); hpen = CreatePen(PS_SOLID, th, RGB(cr, cg, cb)); if (ptype != "bits" && ptype != "pixel") SelectObject(backbuffer, hpen); //SelectObject(hcdc, hbrush); //SelectObject(hcdc, hpen); if (ptype == "rectangle") Rectangle(backbuffer, x, y, x + w, y + h); if (ptype == "point") SetPixel(backbuffer, x, y, RGB(cr, cg, cb)); if (ptype == "ellipse") Ellipse(backbuffer, x, y, x + w, y + h); if (ptype == "circle") Ellipse(backbuffer, x - r / 2, y - r / 2, x + r / 2, y + r / 2); if (ptype == "line"){ new logger(10, "Wguicore--Wview::dispatch(paint)::debug: trying to paint line\n"); MoveToEx(backbuffer, x, y, NULL); LineTo(backbuffer, x + w, y + h); } if (ptype == "pixel") SetPixel(backbuffer, x, y, RGB(cr, cg, cb)); if (ptype == "bits"){ HBITMAP hbm = CreateCompatibleBitmap(hdc, h, w); SelectObject(hcdc, hbm); for (int i = 0; i < h; i++) for (int j = 0; j < w; ++j) SetPixel(hcdc, i, j, pixeldrawer::draw(datamanager::getbyid(x)->get(i * w + j))); StretchBlt(backbuffer, 0, 0, getsize().first, getsize().second, hcdc, 0, 0, h, w, SRCCOPY); DeleteObject(hbm); } delete primitive; DeleteObject(hpen); DeleteObject(hbrush); } BitBlt(hdc, 0, 0, size.first, size.second, backbuffer, 0, 0, SRCCOPY); DeleteDC(hcdc); DeleteDC(backbuffer); EndPaint(hwnd, &ps); } } else if (token->getparam("message") == "mousedown"){ if (onmousedown) (*onmousedown)(this, message); } else if (token->getparam("message") == "mouseup"){ if (onmouseup) (*onmouseup)(this, message); } else if (token->getparam("message") == "mousemove") if (onmousemove) (*onmousemove)(this, message); clean; #undef clean }
void TABLE::CreateEditControl() { if(hEdit || TABLE_ATTRIBUTES::AutoFill() || !TABLE_ATTRIBUTES::CanActivate()) return; long activeRow = TABLE_ATTRIBUTES::ActiveRow(); if(activeRow<0) return; if((activeRow<firstRow) || (activeRow>(firstRow+numVisRows-1))) return; int activeCol = TABLE_ATTRIBUTES::ActiveColumn(); if(!COLUMN::CanEdit(activeCol)) return; RUNTIMEINFO* rtime = (RUNTIMEINFO*)AObjGetRuntimeInfo(theObject); ROW* row = rtime->GetRow(); if(!row->IsSelected(activeRow)) return; int width = COLUMN::ColumnWidth(activeCol); if(width==0) return; int height = TABLE_ATTRIBUTES::CellHeight(); if(TABLE_ATTRIBUTES::RowLines()) height++; int cellY = tblRect.top + ((int)(activeRow - firstRow))*height; if(TABLE_ATTRIBUTES::ShowTitles()) { cellY += (TABLE_ATTRIBUTES::TitleHeight()+1); if(TABLE_ATTRIBUTES::RowLines()) cellY++; } if(TABLE_ATTRIBUTES::RowLines()) height--; int cellX = tblRect.left; for(int i=0; i<activeCol; i++) { if((i>=TABLE_ATTRIBUTES::NumFixedColumns()) && (i<firstColumn)) continue; if(COLUMN::ColumnWidth(i)==0) { if((i==(TABLE_ATTRIBUTES::NumFixedColumns()-1)) && (cellX!=tblRect.left)) cellX++; continue; } cellX += COLUMN::ColumnWidth(i); if(TABLE_ATTRIBUTES::ColumnLines()) cellX++; if(i==(TABLE_ATTRIBUTES::NumFixedColumns()-1)) cellX++; } HDC hDC = GetDC(hTable); HPEN hPen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_WINDOW)); LOGBRUSH lb = {BS_SOLID, GetSysColor(COLOR_WINDOW), 0}; HPEN oldPen = (HPEN)SelectObject(hDC, hPen); HBRUSH hBrush = CreateBrushIndirect(&lb); HBRUSH oldBrush = (HBRUSH)SelectObject(hDC, hBrush); int right = cellX+width; if(right>tblRect.right) right = tblRect.right; Rectangle(hDC, cellX, cellY, right, cellY+height); SelectObject(hDC, oldPen); DeleteObject(hPen); SelectObject(hDC, oldBrush); DeleteObject(hBrush); ReleaseDC(hParentWnd, hDC); cellX += COLUMN::CellCharWidth(activeCol); width -= 2*COLUMN::CellCharWidth(activeCol); if((cellX+width)>tblRect.right) width = tblRect.right - cellX; int offset = 2*TABLE_ATTRIBUTES::CellLeading()/3 + TABLE_ATTRIBUTES::CellAscent() - COLUMN::CellAscent(activeCol); cellY = cellY + offset; height = TABLE_ATTRIBUTES::CellHeight() - offset; editRow = activeRow; editCol = activeCol; char huge* cellPtr = row->GetCell(activeRow, activeCol, FALSE, NULL); UINT length = (UINT)hstrlen(cellPtr) + 1; char* cellStr = new char[length]; hmemcpy(cellStr, cellPtr, length); hEdit = CreateWindow("EDIT", cellStr, WS_CHILD | ES_AUTOHSCROLL, cellX, cellY, width, height, hTable, (HMENU)3, G.hInstance, NULL); delete cellStr; // subclass the edit control SetProp(hEdit, "loPtr", (HANDLE)LOWORD((DWORD)this)); SetProp(hEdit, "hiPtr", (HANDLE)HIWORD((DWORD)this)); SetProp(hEdit, "number", (HANDLE)AObjCheckType(COLUMN::GetObjectID(activeCol), OTYPE_NUMBER)); oldEditControlProc = (WNDPROC)GetWindowLong(hEdit, GWL_WNDPROC); SetWindowLong(hEdit, GWL_WNDPROC, (long)EditControlProc); ShowWindow(hEdit, SW_SHOW); hEditFont =CreateFontIndirect(COLUMN::CellLogFont(activeCol)); SendMessage(hEdit, WM_SETFONT, (WPARAM)hEditFont, MAKELPARAM(TRUE, 0)); SetFocus(hEdit); SendMessage(hEdit, EM_SETSEL, (WPARAM)FALSE, MAKELPARAM(0, -1)); // wipPreventThieves(ParentID, TRUE); SKJ --> need replacement AEvtPostSignalAtMark(theObject, SIGNAL_STARTEDITING); }
//Yeah this truly turned into a mess with the latest additions.. but it sure looks nice ;) void CtrlRegisterList::onPaint(WPARAM wParam, LPARAM lParam) { if (!cpu) return; GetClientRect(wnd, &rect); PAINTSTRUCT ps; HDC hdc; hdc = BeginPaint(wnd, &ps); // TODO: Add any drawing code here... int width = rect.right; //numRows=(numRows&(~1)) + 1; SetBkMode(hdc, TRANSPARENT); DWORD bgColor = 0xffffff; HPEN nullPen=CreatePen(0,0,bgColor); HPEN currentPen=CreatePen(0,0,0); HPEN selPen=CreatePen(0,0,0x808080); LOGBRUSH lbr; lbr.lbHatch=0; lbr.lbStyle=0; lbr.lbColor=bgColor; HBRUSH nullBrush=CreateBrushIndirect(&lbr); lbr.lbColor=0xFFEfE8; HBRUSH currentBrush=CreateBrushIndirect(&lbr); lbr.lbColor=0x70FF70; HBRUSH pcBrush=CreateBrushIndirect(&lbr); HPEN oldPen=(HPEN)SelectObject(hdc,nullPen); HBRUSH oldBrush=(HBRUSH)SelectObject(hdc,nullBrush); HFONT oldFont = (HFONT)SelectObject(hdc,(HGDIOBJ)font); // HICON breakPoint = (HICON)LoadIcon(GetModuleHandle(0),(LPCSTR)IDI_STOP); // HICON breakPointDisable = (HICON)LoadIcon(GetModuleHandle(0),(LPCSTR)IDI_STOPDISABLE); int nc = cpu->GetNumCategories(); for (int i=0; i<nc; i++) { SelectObject(hdc,i==category?currentPen:nullPen); SelectObject(hdc,i==category?pcBrush:nullBrush); Rectangle(hdc,width*i/nc,0,width*(i+1)/nc,rowHeight); const TCHAR *name = cpu->GetCategoryName(i); TextOut(hdc,width*i/nc,1,name,(int)strlen(name)); } int numRows=rect.bottom/rowHeight; for (int i=0; i<numRows; i++) { int rowY1 = rowHeight*(i+1); int rowY2 = rowHeight*(i+2); lbr.lbColor = i==selection?0xffeee0:0xffffff; SelectObject(hdc,currentBrush); SelectObject(hdc,nullPen); Rectangle(hdc,0,rowY1,16,rowY2); if (selecting && i == selection) SelectObject(hdc,selPen); else SelectObject(hdc,nullPen); HBRUSH mojsBrush=CreateBrushIndirect(&lbr); SelectObject(hdc,mojsBrush); //else // SelectObject(hdc,i==0 ? currentBrush : nullBrush); Rectangle(hdc,16,rowY1,width,rowY2); // Check for any changes in the registers. if (lastPC != cpu->GetPC()) { for (int j = 0, n = cpu->GetNumRegsInCategory(0); j < n; ++j) { u32 v = cpu->GetRegValue(0, j); changedCat0Regs[j] = v != lastCat0Values[j]; lastCat0Values[j] = v; } lastPC = cpu->GetPC(); } SelectObject(hdc,currentBrush); DeleteObject(mojsBrush); if (i<cpu->GetNumRegsInCategory(category)) { char temp[256]; int temp_len = sprintf(temp,"%s",cpu->GetRegName(category,i)); SetTextColor(hdc,0x600000); TextOut(hdc,17,rowY1,temp,temp_len); SetTextColor(hdc,0x000000); cpu->PrintRegValue(category,i,temp); if (category == 0 && changedCat0Regs[i]) SetTextColor(hdc, 0x0000FF); else SetTextColor(hdc,0x004000); TextOut(hdc,77,rowY1,temp,(int)strlen(temp)); } /* } SetTextColor(hdc,0x007000); TextOut(hdc,70,rowY1,dis,strlen(dis)); if (desc[0]==0) strcpy(desc,debugger->getDescription(address)); SetTextColor(hdc,0x0000FF); //char temp[256]; //UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE); if (strlen(desc)) TextOut(hdc,280,rowY1,desc,strlen(desc)); if (debugger->isBreakpoint(address)) { DrawIconEx(hdc,2,rowY1,breakPoint,32,32,0,0,DI_NORMAL); } }*/ } SelectObject(hdc,oldFont); SelectObject(hdc,oldPen); SelectObject(hdc,oldBrush); DeleteObject(nullPen); DeleteObject(currentPen); DeleteObject(selPen); DeleteObject(nullBrush); DeleteObject(pcBrush); DeleteObject(currentBrush); // DestroyIcon(breakPoint); // DestroyIcon(breakPointDisable); EndPaint(wnd, &ps); }
//Yeah this truly turned into a mess with the latest additions.. but it sure looks nice ;) void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) { struct branch { int src,dst,srcAddr; }; branch branches[256]; int numBranches=0; GetClientRect(wnd, &rect); PAINTSTRUCT ps; HDC hdc; hdc = BeginPaint(wnd, &ps); // TODO: Add any drawing code here... int width = rect.right; int numRows=(rect.bottom/rowHeight)/2+1; //numRows=(numRows&(~1)) + 1; SetBkMode(hdc, TRANSPARENT); DWORD bgColor = 0xffffff; HPEN nullPen=CreatePen(0,0,bgColor); HPEN currentPen=CreatePen(0,0,0); HPEN selPen=CreatePen(0,0,0x808080); LOGBRUSH lbr; lbr.lbHatch=0; lbr.lbStyle=0; lbr.lbColor=bgColor; HBRUSH nullBrush=CreateBrushIndirect(&lbr); lbr.lbColor=0xFFEfE8; HBRUSH currentBrush=CreateBrushIndirect(&lbr); lbr.lbColor=0x70FF70; HBRUSH pcBrush=CreateBrushIndirect(&lbr); HPEN oldPen=(HPEN)SelectObject(hdc,nullPen); HBRUSH oldBrush=(HBRUSH)SelectObject(hdc,nullBrush); HFONT oldFont = (HFONT)SelectObject(hdc,(HGDIOBJ)font); HICON breakPoint = (HICON)LoadIcon(hMod,(LPCWSTR)IDI_BRKPT); HICON breakPointDisable = (HICON)LoadIcon(hMod,(LPCWSTR)IDI_BRKPTDIS); int i; for (i=-numRows; i<=numRows; i++) { unsigned int address=curAddress + i*align; int rowY1 = rect.bottom/2 + rowHeight*i - rowHeight/2; int rowY2 = rect.bottom/2 + rowHeight*i + rowHeight/2; wchar temp[256]; swprintf(temp,L"%08X",address); TCHAR desc[256]=L""; wcscpy(desc,debugger->getDescription(address)); // do this before getColor() lbr.lbColor=debugger->getColor(address); //SelectObject(hdc,currentBrush); SelectObject(hdc,nullPen); Rectangle(hdc,0,rowY1,16,rowY2); if (selecting && address == (u32)selection) SelectObject(hdc,selPen); else SelectObject(hdc,i==0 ? currentPen : nullPen); HBRUSH mojsBrush=CreateBrushIndirect(&lbr); SelectObject(hdc,mojsBrush); if (address == debugger->getPC()) SelectObject(hdc,pcBrush); //else // SelectObject(hdc,i==0 ? currentBrush : nullBrush); Rectangle(hdc,16,rowY1,width,rowY2); SelectObject(hdc,currentBrush); DeleteObject(mojsBrush); SetTextColor(hdc,0x600000); TextOut(hdc,17,rowY1,temp,(int)wcslen(temp)); SetTextColor(hdc,0x000000); TCHAR *dis = debugger->disasm(address); TCHAR *dis2=_tcschr(dis,'\t'); if (dis2) { *dis2=0; dis2++; wchar *mojs=wcsstr(dis2,L"0x8"); if (mojs) for (int i=0; i<8; i++) { bool found=false; for (int j=0; j<22; j++) { if (mojs[i+2]==L"0123456789ABCDEFabcdef"[j]) found=true; } if (!found) { mojs=0; break; } } if (mojs) { int offs; swscanf(mojs+2,L"%08X",&offs); branches[numBranches].src=rowY1 + rowHeight/2; branches[numBranches].srcAddr=address/align; branches[numBranches++].dst=(int)(rowY1+((__int64)offs-(__int64)address)*rowHeight/align + rowHeight/2); // sprintf(desc,"-->%s", debugger->getDescription(offs)); SetTextColor(hdc,0x600060); } else SetTextColor(hdc,0x000000); TextOut(hdc,198,rowY1,dis2,(int)wcslen(dis2)); } SetTextColor(hdc,0x007000); TextOut(hdc,90,rowY1,dis,(int)wcslen(dis)); SetTextColor(hdc,0x0000FF); //char temp[256]; //UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE); if (wcslen(desc)) TextOut(hdc,320,rowY1,desc,(int)wcslen(desc)); if (debugger->isBreakpoint(address)) { DrawIconEx(hdc,2,rowY1,breakPoint,32,32,0,0,DI_NORMAL); } } SelectObject(hdc,currentPen); for (i=0; i<numBranches; i++) { int x=250+(branches[i].srcAddr%9)*8; MoveToEx(hdc,x-2,branches[i].src,0); if (branches[i].dst<rect.bottom+200 && branches[i].dst>-200) { LineTo(hdc,x+2,branches[i].src); LineTo(hdc,x+2,branches[i].dst); LineTo(hdc,x-4,branches[i].dst); MoveToEx(hdc,x,branches[i].dst-4,0); LineTo(hdc,x-4,branches[i].dst); LineTo(hdc,x+1,branches[i].dst+5); } else { LineTo(hdc,x+4,branches[i].src); //MoveToEx(hdc,x+2,branches[i].dst-4,0); //LineTo(hdc,x+6,branches[i].dst); //LineTo(hdc,x+1,branches[i].dst+5); } //LineTo(hdc,x,branches[i].dst+4); //LineTo(hdc,x-2,branches[i].dst); } SelectObject(hdc,oldFont); SelectObject(hdc,oldPen); SelectObject(hdc,oldBrush); DeleteObject(nullPen); DeleteObject(currentPen); DeleteObject(selPen); DeleteObject(nullBrush); DeleteObject(pcBrush); DeleteObject(currentBrush); DestroyIcon(breakPoint); DestroyIcon(breakPointDisable); EndPaint(wnd, &ps); }
static HBRUSH wf_create_brush(wfInfo * wfi, RD_BRUSH * brush, int color, int bpp) { HBRUSH br; LOGBRUSH lbr; HBITMAP pattern = NULL; uint8 * cdata; int i; uint8 ipattern[8]; // Style lbr.lbStyle = brush->style; // Color if (lbr.lbStyle == BS_DIBPATTERN || lbr.lbStyle == BS_DIBPATTERN8X8 || lbr.lbStyle == BS_DIBPATTERNPT) { lbr.lbColor = DIB_RGB_COLORS; } else { lbr.lbColor = color; } // Hatch if (lbr.lbStyle == BS_PATTERN || lbr.lbStyle == BS_PATTERN8X8) { if (brush->bd == 0) /* rdp4 brush */ { for (i = 0; i != 8; i++) { ipattern[7 - i] = brush->pattern[i]; } cdata = wf_glyph_convert(wfi, 8, 8, ipattern); pattern = CreateBitmap(8, 8, 1, 1, cdata); lbr.lbHatch = (ULONG_PTR)pattern; free(cdata); } else if (brush->bd->color_code > 1) /* > 1 bpp */ { pattern = wf_create_dib(wfi, 8, 8, bpp, 1, brush->bd->data); lbr.lbHatch = (ULONG_PTR)pattern; } else { cdata = wf_glyph_convert(wfi, 8, 8, brush->bd->data); pattern = CreateBitmap(8, 8, 1, 1, cdata); lbr.lbHatch = (ULONG_PTR)pattern; free(cdata); } } else if (lbr.lbStyle == BS_HATCHED) { lbr.lbHatch = brush->pattern[0]; } else { lbr.lbHatch = 0; } br = CreateBrushIndirect(&lbr); SetBrushOrgEx(wfi->drw->hdc, brush->xorigin, brush->yorigin, NULL); if (pattern != NULL) { DeleteObject(pattern); } return br; }
static bool rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style) { x1++; y1++; x0 = MAX(x0, 0); y0 = MAX(y0, 0); if (!((current_gui == NULL) || (thumbnail))) { x1 = MIN(x1, gui_window_width(current_gui)); y1 = MIN(y1, gui_window_height(current_gui)); } #if NSWS_PLOT_DEBUG LOG(("rectangle from %d,%d to %d,%d thumbnail %d", x0, y0, x1, y1, thumbnail)); #endif HDC hdc = doublebuffering ? bufferdc : GetDC(current_hwnd); if (hdc == NULL) { return false; } RECT *clipr = gui_window_clip_rect(current_gui); if (clipr == NULL) clipr = &localhistory_clip; HRGN clipregion = CreateRectRgnIndirect(clipr); if (clipregion == NULL) { if (!doublebuffering) ReleaseDC(current_hwnd, hdc); return false; } COLORREF pencol = (DWORD)(style->stroke_colour & 0x00FFFFFF); DWORD penstyle = PS_GEOMETRIC | (style->stroke_type == PLOT_OP_TYPE_DOT ? PS_DOT : (style->stroke_type == PLOT_OP_TYPE_DASH ? PS_DASH : (style->stroke_type == PLOT_OP_TYPE_NONE ? PS_NULL : 0))); LOGBRUSH lb = {BS_SOLID, pencol, 0}; LOGBRUSH lb1 = {BS_SOLID, style->fill_colour, 0}; if (style->fill_type == PLOT_OP_TYPE_NONE) lb1.lbStyle = BS_HOLLOW; HPEN pen = ExtCreatePen(penstyle, style->stroke_width, &lb, 0, NULL); if (pen == NULL) { DeleteObject(clipregion); if (!doublebuffering) ReleaseDC(current_hwnd, hdc); return false; } HGDIOBJ penbak = SelectObject(hdc, (HGDIOBJ) pen); if (penbak == NULL) { DeleteObject(clipregion); DeleteObject(pen); if (!doublebuffering) ReleaseDC(current_hwnd, hdc); return false; } HBRUSH brush = CreateBrushIndirect(&lb1); if (brush == NULL) { DeleteObject(clipregion); SelectObject(hdc, penbak); DeleteObject(pen); if (!doublebuffering) ReleaseDC(current_hwnd, hdc); return false; } HGDIOBJ brushbak = SelectObject(hdc, (HGDIOBJ) brush); if (brushbak == NULL) { DeleteObject(clipregion); SelectObject(hdc, penbak); DeleteObject(pen); DeleteObject(brush); if (!doublebuffering) ReleaseDC(current_hwnd, hdc); return false; } RECT r; r.left = x0; r.top = y0; r.right = x1; r.bottom = y1; SelectClipRgn(hdc, clipregion); Rectangle(hdc, x0, y0, x1, y1); SelectClipRgn(hdc, NULL); /* ValidateRect(current_hwnd, &r); */ pen = SelectObject(hdc, penbak); brush = SelectObject(hdc, brushbak); DeleteObject(clipregion); DeleteObject(pen); DeleteObject(brush); if (!doublebuffering) ReleaseDC(current_hwnd, hdc); return true; }
BOOL CVFPUDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: { return TRUE; } break; case WM_COMMAND: { // CtrlMemView *mv = CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_MEMVIEW)); //switch (LOWORD(wParam)) //{ //} } break; case WM_NOTIFY: { HWND tabs = GetDlgItem(m_hDlg, IDC_TABDATATYPE); NMHDR* pNotifyMessage = NULL; pNotifyMessage = (LPNMHDR)lParam; if (pNotifyMessage->hwndFrom == tabs) { mode = TabCtrl_GetCurSel (tabs); InvalidateRect(m_hDlg,0,0); } break; } case WM_SIZE: Size(); break; case WM_PAINT: { HWND wnd = m_hDlg; RECT rect; GetClientRect(wnd, &rect); PAINTSTRUCT p; HDC hdc = BeginPaint(wnd, &p); SetBkMode(hdc, TRANSPARENT); DWORD bgColor = 0xffffff; HPEN nullPen=CreatePen(0,0,bgColor); HPEN currentPen=CreatePen(0,0,0); HPEN selPen=CreatePen(0,0,0x808080); LOGBRUSH lbr; lbr.lbHatch=0; lbr.lbStyle=0; lbr.lbColor=bgColor; HBRUSH nullBrush=CreateBrushIndirect(&lbr); lbr.lbColor=0xFFEfE8; HBRUSH currentBrush=CreateBrushIndirect(&lbr); lbr.lbColor=0x70FF70; HBRUSH pcBrush=CreateBrushIndirect(&lbr); HPEN oldPen=(HPEN)SelectObject(hdc,currentPen); HBRUSH oldBrush=(HBRUSH)SelectObject(hdc,nullBrush); HFONT oldFont = (HFONT)SelectObject(hdc,(HGDIOBJ)font); enum { rowHeight = 15, columnWidth = 80, xStart = columnWidth/2, yStart = 30, }; for (int matrix = 0; matrix<8; matrix++) { int my = (int)(yStart + matrix * rowHeight * 5.5f); Rectangle(hdc, 0, my, xStart, my+rowHeight); char temp[256]; sprintf_s(temp, "M%i00", matrix); TextOut(hdc,3,my+2,temp,strlen(temp)); Rectangle(hdc,xStart,my+rowHeight,xStart+columnWidth*4,my+5*rowHeight); for (int column = 0; column<4; column++) { int y = my; int x = column * columnWidth + xStart; Rectangle(hdc, x, y, x + columnWidth, y+rowHeight); char temp[256]; sprintf_s(temp, "R%i0%i", matrix, column); TextOut(hdc,x+3,y+2,temp,strlen(temp)); Rectangle(hdc, 0, y+rowHeight*(column+1), xStart, y+rowHeight*(column+2)); sprintf_s(temp, "C%i%i0", matrix, column); TextOut(hdc,3,y+rowHeight*(column+1)+1,temp,strlen(temp)); y+=rowHeight; for (int row = 0; row<4; row++) { float val = mipsr4k.v[column*32+row+matrix*4]; u32 hex = *((u32*)&val); char temp[256]; switch (mode) { case 0: sprintf_s(temp,"%f",val); break; // case 1: sprintf_s(temp,"??"); break; case 2: sprintf_s(temp,"0x%08x",hex); break; default: sprintf_s(temp,"%f",val); break; } TextOut(hdc,x+3,y+2,temp,strlen(temp)); y+=rowHeight; } } } SelectObject(hdc,oldFont); SelectObject(hdc,oldPen); SelectObject(hdc,oldBrush); DeleteObject(nullPen); DeleteObject(currentPen); DeleteObject(selPen); DeleteObject(nullBrush); DeleteObject(pcBrush); DeleteObject(currentBrush); EndPaint(m_hDlg, &p); } break; case WM_CLOSE: Show(false); break; } return 0; }
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprev, PSTR cmdline, int ishow) { HWND hwnd; MSG msg; WNDCLASSEX wndclassex = {0}; LOGBRUSH b_ground; // Set up background image b_ground.lbStyle = BS_PATTERN; b_ground.lbColor = DIB_RGB_COLORS; b_ground.lbHatch = (long)LoadImage(NULL,"win_bkgrd.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); // Init the fields we care about wndclassex.cbSize = sizeof(WNDCLASSEX); wndclassex.style = CS_HREDRAW | CS_VREDRAW; wndclassex.lpfnWndProc = WinProc; wndclassex.hInstance = hinstance; wndclassex.lpszClassName = class_name; wndclassex.hCursor = (HCURSOR)LoadImage(NULL, MAKEINTRESOURCE(IDC_ARROW), IMAGE_CURSOR, 0, 0, LR_SHARED); // If LoadImage() cannot open "win_bkgrnd.bmp" it will return NULL // We don't want to try and call CreateBrushIndirect() if we don't have a valid // logbrush to pass in so we check first if(b_ground.lbHatch) wndclassex.hbrBackground = CreateBrushIndirect(&b_ground); else wndclassex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); // Make it white RegisterClassEx(&wndclassex); hwnd = CreateWindowEx(NULL, // No extended style class_name, "www.GameTutorials.com -- CD-Player", WS_SYSMENU | WS_CAPTION, // We won't be able to resize the window CW_USEDEFAULT, CW_USEDEFAULT, WINDOW_WIDTH, WINDOW_HEIGHT, NULL, NULL, hinstance, NULL); ShowWindow(hwnd, ishow); UpdateWindow(hwnd); while(1) { // If we get a Window Message -- Handle it appropriately if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if(msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } } UnregisterClass(class_name,hinstance); // Free up WNDCLASSEX return msg.wParam; // And we're out :) }
BOOL CALLBACK main_RCONDialogCallback( HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam ) { char szBuffer[128]; switch ( Message ) { case WM_CTLCOLORSTATIC: switch ( GetDlgCtrlID( (HWND) lParam )) { // Paint these two labels (and the disconnct button's background) white. case IDCANCEL: case IDC_STATUS: case IDC_SERVERSUBINFO: return (LRESULT) g_hWhiteBrush; // Ignore everything else. default: return NULL; } break; case WM_PAINT: { // Paint the top of the form white. PAINTSTRUCT Ps; RECT r; r.left = 0; r.top = 0; r.bottom = 48; r.right = 800; main_PaintRectangle( BeginPaint(hDlg, &Ps), &r, RGB(255, 255, 255)); } break; case WM_INITDIALOG: // Hide the old dialog, and take its place. ShowWindow( g_hDlg, SW_HIDE ); g_hDlg = hDlg; SendDlgItemMessage( hDlg, IDC_CONSOLEBOX, EM_SETLIMITTEXT, 4096, 0 ); SendDlgItemMessage( hDlg, IDC_INPUTBOX, EM_SETLIMITTEXT, 256, 0 ); SetWindowText( hDlg, g_szHostname ); main_SetState( STATE_CONNECTED ); Printf( "\nMap: %s\n", g_szMapname ); // Fill the console with the received history. sprintf( szBuffer, "Connected to \"%s\".", g_szHostname ); SetDlgItemText( hDlg, IDC_CONSOLEBOX, szBuffer ); SetDlgItemText( hDlg, IDC_STATUS, szBuffer ); main_UpdateTrayTooltip( szBuffer ); Printf_NoTimestamp( "\n" ); for( std::list<FString>::iterator i = g_RecentConsoleHistory.begin(); i != g_RecentConsoleHistory.end(); ++i ) Printf_NoTimestamp( "%s", *i ); g_RecentConsoleHistory.clear(); // Set up the top, white section. SendMessage( GetDlgItem( g_hDlg, IDC_STATUS ), WM_SETFONT, (WPARAM) CreateFont( 13, 0, 0, 0, 600, 0, 0, 0, 0, 0, 0, 0, 0, "Tahoma" ), (LPARAM) 1 ); LOGBRUSH LogBrush; LogBrush.lbStyle = BS_SOLID; LogBrush.lbColor = RGB( 255, 255, 255 ); g_hWhiteBrush = CreateBrushIndirect( &LogBrush ); main_UpdateServerStatus( ); // Set up the player list LVCOLUMN ColumnData; ColumnData.mask = LVCF_FMT|LVCF_TEXT|LVCF_WIDTH; ColumnData.fmt = LVCFMT_LEFT; ColumnData.cx = 192; ColumnData.pszText = "Name"; ColumnData.cchTextMax = 64; ColumnData.iSubItem = 0; SendDlgItemMessage( hDlg, IDC_PLAYERLIST, LVM_INSERTCOLUMN, COLUMN_NAME, (LPARAM)&ColumnData ); // Add the cached list of players. LVITEM Item; Item.mask = LVIF_TEXT; Item.iSubItem = COLUMN_NAME; Item.iItem = MAXPLAYERS; while ( g_InitialPlayers.size( ) ) { Item.pszText = (LPSTR) g_InitialPlayers.front( ).GetChars( ); g_InitialPlayers.pop_front( ); SendDlgItemMessage( g_hDlg, IDC_PLAYERLIST, LVM_INSERTITEM, 0, (LPARAM)&Item ) ; } // Load the icon. SendMessage( hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM) (HICON) LoadImage( g_hInst, MAKEINTRESOURCE( AAA_MAIN_ICON ), IMAGE_ICON, 16, 16, LR_SHARED )); SendMessage( hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)LoadIcon( g_hInst, MAKEINTRESOURCE( AAA_MAIN_ICON ))); // Set up the status bar. g_hDlgStatusBar = CreateStatusWindow(WS_CHILD | WS_VISIBLE, (LPCTSTR)NULL, hDlg, IDC_STATIC); g_bRCONDialogVisible = true; break; case WM_COMMAND: switch ( LOWORD( wParam )) { // This also occurs when esc is pressed. case IDCANCEL: main_Quit( ); break; // "Send" button. case IDC_SEND: char szCommand[256]; GetDlgItemText( hDlg, IDC_INPUTBOX, szCommand, sizeof( szCommand )); NETWORK_ClearBuffer( &g_MessageBuffer ); NETWORK_WriteByte( &g_MessageBuffer.ByteStream, CLRC_COMMAND ); if ( szCommand[0] == ':' ) // If the text in the send buffer begins with a :, the admin is just talking. { char szBuffer2[256 + 4]; sprintf( szBuffer2, "say %s", szCommand + 1 ); NETWORK_WriteString( &g_MessageBuffer.ByteStream, szBuffer2 ); break; } else if ( szCommand[0] == '/' ) // If the text in the send buffer begins with a slash, error out -- Skulltag used to require you to do this to send commands. { Printf( "You longer have to prefix commands with a / to send them.\n" ); SetDlgItemText( hDlg, IDC_INPUTBOX, szCommand + 1 ); SendMessage( GetDlgItem( hDlg, IDC_INPUTBOX ), EM_SETSEL, strlen( szCommand ) - 1, strlen( szCommand ) - 1 ); break; } else NETWORK_WriteString( &g_MessageBuffer.ByteStream, szCommand ); NETWORK_LaunchPacket( &g_MessageBuffer, g_ServerAddress ); time( &g_tLastSentCommand ); SetDlgItemText( hDlg, IDC_INPUTBOX, "" ); break; } break; case WM_SYSCOMMAND: // Hide the window when minimized. if ( wParam == SC_MINIMIZE ) ShowWindow( hDlg, SW_HIDE ); else DefWindowProc( hDlg, Message, wParam, lParam ); break; case WM_CLOSE: main_Quit( ); break; case WM_DESTROY: Shell_NotifyIcon( NIM_DELETE, &g_NotifyIconData ); PostQuitMessage( 0 ); break; case UWM_TRAY_TRAYID: return main_TrayIconClicked( hDlg, lParam ); default: return FALSE; } return TRUE; // If this is false, minimizing the window won't hide it. }
// ----------------------------------------------------------------------- // Initialize Form int CALLBACK FRMAboutProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { RECT SplashRect; PAINTSTRUCT AboutPs; switch(uMsg) { case WM_INITDIALOG: MainAbouthWnd = hwndDlg; AboutSerFont8 = GDIObtainFont("MS Sans Serif", 8, hwndDlg, 0, 0); AboutCourFont8 = GDIObtainFont("Courier New", 9, hwndDlg, 0, 0); CreatePictureBox(0, 0, 500, 194, hwndDlg, LoadBitmap(ApphInstance, MAKEINTRESOURCE(MBMP_BASE + MBMP_TITLE)), IMAGE_BITMAP, 0, 0, SS_CENTERIMAGE); AbouthWnd = CreateLabel(4, 195, 302, 104, hwndDlg, "", 2, &FrmAboutTypeWriterHook, 0, 0); ControlSetText(hwndDlg, "About " + (CStr) AppTitle); FreezeTimer = 1; AboutPosInText = 1; AboutPosOnScreen = 0; AbLine1 = ""; AbLine2 = ""; AbLine3 = ""; AbLine4 = ""; AbLine5 = ""; AbLine6 = ""; AbLine7 = ""; AbLine8 = ""; AboutScrollAmount = GDIGetTextHeight(AbouthWnd, AboutCourFont8, "hg"); AboutText = "\r"; AboutText = AboutText + (CStr) Requesters + (CStr) "\r"; AboutText = AboutText + (CStr) "Integrated Development Environment\r"; AboutText = AboutText + (CStr) "(Build: " __DATE__ + (CStr) ")\r\r"; AboutText = AboutText + (CStr) "Written by Franck Charlet.\r\r"; AboutText = AboutText + (CStr) "I would like to thank the following\r"; AboutText = AboutText + (CStr) "people who have more or less,\r"; AboutText = AboutText + (CStr) "directly or indirectly contributed\r"; AboutText = AboutText + (CStr) "to this marvellous tool of mine:\r\r"; AboutText = AboutText + (CStr) "Barry Allyn (cmax)\r"; AboutText = AboutText + (CStr) "EliCZ (nt driver model)\r"; AboutText = AboutText + (CStr) "Cppreference.com people (cpp.chm)\r"; AboutText = AboutText + (CStr) "Jordan Russel (Inno setup)\r"; AboutText = AboutText + (CStr) "Me (who ?)\r"; AboutText = AboutText + (CStr) "Roman Novgorodov (x86eas.hlp)\r"; AboutText = AboutText + (CStr) "Steve Hutchesson (masm32)\r"; AboutText = AboutText + (CStr) "So long...\r\r"; AboutText = AboutText + (CStr) "If you can read this you're dying.\r\r\r\r\r\r\r"; AboutTimerHandle = SetTimer(hwndDlg, 1, 105, &AboutTimerNotify); AboutBrush.lbStyle = BS_SOLID; AboutBrush.lbHatch = 0; AboutBrush.lbColor = ABOUT_BACKCOLOR; hAboutBrush = CreateBrushIndirect(&AboutBrush); return(0); case WM_ERASEBKGND: GetClientRect(hwndDlg, &SplashRect); FillRect((HDC) wParam, &SplashRect, hAboutBrush); return(1); case WM_PAINT: BeginPaint(hwndDlg, &AboutPs); EndPaint(hwndDlg, &AboutPs); break; case WM_CLOSE: if(hAboutBrush != 0) DeleteObject(hAboutBrush); if(AboutTimerHandle != 0) KillTimer(hwndDlg, 1); if(AboutCourFont8 != 0) DeleteObject(AboutCourFont8); if(AboutSerFont8 != 0) DeleteObject(AboutSerFont8); FreezeTimer = 0; EndDialog(hwndDlg, 0); break; } return(0); }
BOOL CALLBACK main_ConnectDialogCallback( HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam ) { char szBuffer[128]; switch ( Message ) { case WM_CTLCOLORSTATIC: switch ( GetDlgCtrlID( (HWND) lParam )) { // Paint these two labels white. case IDC_INTROTEXT: case IDC_DESCTEXT: return (LRESULT) g_hWhiteBrush; // Ignore everything else. default: return NULL; } break; case WM_PAINT: { // Paint the top of the form white. PAINTSTRUCT Ps; RECT r; r.left = 0; r.top = 3; r.bottom = 55; r.right = 400; main_PaintRectangle( BeginPaint(hDlg, &Ps), &r, RGB(255, 255, 255)); } break; case WM_INITDIALOG: { g_hDlg = hDlg; // Load the icon. SendMessage( hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM) (HICON) LoadImage( g_hInst, MAKEINTRESOURCE( AAA_MAIN_ICON ), IMAGE_ICON, 16, 16, LR_SHARED )); SendMessage( hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)LoadIcon( g_hInst, MAKEINTRESOURCE( AAA_MAIN_ICON ))); //============================== // Create the notification icon. //============================== ZeroMemory( &g_NotifyIconData, sizeof( g_NotifyIconData )); g_NotifyIconData.cbSize = sizeof( g_NotifyIconData ); g_NotifyIconData.hWnd = hDlg; g_NotifyIconData.uID = 0; g_NotifyIconData.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP; g_NotifyIconData.uCallbackMessage = UWM_TRAY_TRAYID; g_NotifyIconData.hIcon = (HICON) LoadImage( g_hInst, MAKEINTRESOURCE( AAA_MAIN_ICON ), IMAGE_ICON, 16, 16, LR_SHARED ); lstrcpy( g_NotifyIconData.szTip, g_szTooltip ); Shell_NotifyIcon( NIM_ADD, &g_NotifyIconData ); //================== // Create the menus. //================== // Create the favorites menu. g_hFavoritesMenu = CreatePopupMenu( ); int iIndex = 1; for( std::vector<FAVORITE_s>::iterator i = g_Favorites.begin(); i != g_Favorites.end(); ++i ) AppendMenu( g_hFavoritesMenu, MF_STRING, IDR_DYNAMIC_MENU + iIndex++, (LPCTSTR)(&(*i->szName)) ); // Create the tray menu. g_hTrayMenu = CreatePopupMenu( ); AppendMenu( g_hTrayMenu, MF_STRING, IDR_TOGGLE, "Show/Hide" ); AppendMenu( g_hTrayMenu, MF_STRING|MF_POPUP, (UINT)g_hFavoritesMenu, "Favorites"); AppendMenu( g_hTrayMenu, MF_SEPARATOR, 0, 0 ); AppendMenu( g_hTrayMenu, MF_STRING, IDR_EXIT, "Exit" ); // Create the file menu. HMENU hFileMenu = CreatePopupMenu( ); AppendMenu( hFileMenu, MF_STRING, IDR_EXIT, "Exit" ); // Create the file menu. HMENU hHelpMenu = CreatePopupMenu( ); AppendMenu( hHelpMenu, MF_STRING, IDR_ABOUT, "About..." ); // Create the main menu. g_hMainMenu = CreateMenu( ); AppendMenu( g_hMainMenu, MF_STRING|MF_POPUP, (UINT)hFileMenu, "File" ); AppendMenu( g_hMainMenu, MF_STRING|MF_POPUP, (UINT)g_hFavoritesMenu, "Favorites"); AppendMenu( g_hMainMenu, MF_STRING|MF_POPUP, (UINT)hHelpMenu, "Help"); AppendMenu( g_hMainMenu, MF_SEPARATOR, 0, 0 ); SetMenu( hDlg, g_hMainMenu ); // Set up the status bar. g_hDlgStatusBar = CreateStatusWindow( WS_CHILD | WS_VISIBLE, (LPCTSTR)NULL, hDlg, IDC_STATIC ); // Set up the top, white section. SendMessage( GetDlgItem( g_hDlg, IDC_INTROTEXT ), WM_SETFONT, (WPARAM) CreateFont( 13, 0, 0, 0, 600, 0, 0, 0, 0, 0, 0, 0, 0, "Tahoma" ), (LPARAM) 1 ); LOGBRUSH LogBrush; LogBrush.lbStyle = BS_SOLID; LogBrush.lbColor = RGB( 255, 255, 255 ); g_hWhiteBrush = CreateBrushIndirect( &LogBrush ); // Load the server address that was used last time. if ( g_Config.HaveSections( ) && g_Config.SetSection( "Settings", true ) && g_Config.GetValueForKey( "LastServer" ) ) SetDlgItemText( hDlg, IDC_SERVERIP, g_Config.GetValueForKey( "LastServer" ) ); } break; case WM_COMMAND: // Selecting a favorite from the menu? if ( LOWORD( wParam ) > IDR_DYNAMIC_MENU && LOWORD( wParam ) <= IDR_DYNAMIC_MENU + g_Favorites.size( )) { main_ConnectToFavorite( LOWORD( wParam ) - IDR_DYNAMIC_MENU - 1 ); return TRUE; } switch ( LOWORD( wParam )) { // This also occurs when esc is pressed. case IDCANCEL: if ( g_State == STATE_CONNECTING ) { main_SetState( STATE_WAITING ); main_EnableConnectionButtons( TRUE ); main_UpdateStatusbar( "Cancelled." ); } else main_Quit( ); break; // The "connect" button. case IDOK: // Disable all the inputs. main_EnableConnectionButtons( FALSE ); // Read in what the user gave us. GetDlgItemText( hDlg, IDC_SERVERIP, szBuffer, 128 ); NETWORK_StringToAddress( szBuffer, &g_ServerAddress ); GetDlgItemText( hDlg, IDC_PASSWORD, g_szPassword, 128 ); // If the user didn't specify a port, use the default one. if ( g_ServerAddress.usPort == 0 ) NETWORK_SetAddressPort( g_ServerAddress, DEFAULT_SERVER_PORT ); // Do some quick error checking. if ( !strlen( szBuffer )) MessageBox( hDlg, "You should probably enter a server address.", "Input error.", MB_ICONEXCLAMATION ); else if ( strlen( g_szPassword ) < 4 ) MessageBox( hDlg, "RCON passwords must be at least four characters long.", "Input error.", MB_ICONEXCLAMATION ); else { main_AttemptConnection( ); break; } // Re-enable the form so the user can try again. main_EnableConnectionButtons( TRUE ); break; case IDR_EXIT: main_Quit( ); break; case IDR_ABOUT: DialogBox( g_hInst, MAKEINTRESOURCE( IDD_ABOUTDIALOG ), hDlg, main_AboutDialogCallback ); break; } break; case WM_SYSCOMMAND: // Hide the window when minimized. if ( wParam == SC_MINIMIZE ) ShowWindow( hDlg, SW_HIDE ); else DefWindowProc( hDlg, Message, wParam, lParam ); break; case WM_CLOSE: main_Quit( ); break; case WM_DESTROY: Shell_NotifyIcon( NIM_DELETE, &g_NotifyIconData ); PostQuitMessage( 0 ); break; case UWM_TRAY_TRAYID: return main_TrayIconClicked( hDlg, lParam ); default: return FALSE; } return TRUE; }
VOID CMimicsArcCtrl::DrawCtrl(HDC hDC, CONST RECT *pRect, BOOL bShape) { INT nPt; INT nPts; INT nMode; HPEN hOldPen; HPEN hBorderPen; POINT ptRadial[2]; double fxRadial; double fyRadial; HBRUSH hOldBrush; HBRUSH hInteriorBrush; HBITMAP hInteriorBitmap; LOGBRUSH sInteriorBrush; COLORREF nOldColor[2]; if ((hBorderPen = CreatePen(PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_MITER | m_nBorderStyle, m_nBorderSize, GetNearestColor(hDC, (!bShape) ? m_nBorderColor : VGA_COLOR_WHITE)))) { if ((hInteriorBitmap = LoadBitmap(GetModuleInstance(), (m_nInteriorHatch == HT_SOLID || m_nInteriorHatch < 0) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHSOLID) : ((m_nInteriorHatch == HT_HORIZONTAL) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHHORIZONTAL) : ((m_nInteriorHatch == HT_VERTICAL) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHVERTICAL) : ((m_nInteriorHatch == HT_BDIAGONAL) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHDIAGONALDOWN) : ((m_nInteriorHatch == HT_FDIAGONAL) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHDIAGONALUP) : ((m_nInteriorHatch == HT_CROSS) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHCROSS) : ((m_nInteriorHatch == HT_DIAGCROSS) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHCROSSDIAGONAL) : ((m_nInteriorHatch == HT_LPOINTS) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHPOINTSLOW) : ((m_nInteriorHatch == HT_MPOINTS) ? MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHPOINTSMEDIUM) : MAKEINTRESOURCE(IDB_MIMICSOBJECTCTLHATCHPOINTSHIGH)))))))))))) { sInteriorBrush.lbStyle = (m_nInteriorColor != (COLORREF)-1) ? ((m_nInteriorHatch > 0) ? BS_PATTERN : BS_SOLID) : BS_HOLLOW; sInteriorBrush.lbColor = (sInteriorBrush.lbStyle == BS_SOLID) ? GetNearestColor(hDC, (!bShape) ? m_nInteriorColor : VGA_COLOR_WHITE) : 0; sInteriorBrush.lbHatch = (sInteriorBrush.lbStyle == BS_PATTERN) ? (ULONG_PTR)hInteriorBitmap : (ULONG_PTR)NULL; if ((hInteriorBrush = CreateBrushIndirect(&sInteriorBrush)) != (HBRUSH)NULL) { if ((hOldPen = (HPEN)SelectObject(hDC, hBorderPen)) != (HPEN)NULL) { if ((hOldBrush = (HBRUSH)SelectObject(hDC, hInteriorBrush))) { for (nPt = 0, nPts = sizeof(ptRadial) / sizeof(POINT); nPt < nPts; nPt++) { fxRadial = (INT)((double)(pRect->left + pRect->right) / 2.0 + ((double)(pRect->right - pRect->left + pRect->bottom - pRect->top) / 2.0)*cos(2.0*M_PI - m_ptRadial[nPt])); fyRadial = (INT)((double)(pRect->top + pRect->bottom) / 2.0 + ((double)(pRect->right - pRect->left + pRect->bottom - pRect->top) / 2.0)*sin(2.0*M_PI - m_ptRadial[nPt])); ptRadial[nPt].x = (fxRadial >= 0.0) ? (INT)(fxRadial + 0.5) : (INT)(fxRadial - 0.5); ptRadial[nPt].y = (fyRadial >= 0.0) ? (INT)(fyRadial + 0.5) : (INT)(fyRadial - 0.5); } for (nMode = SetBkMode(hDC, OPAQUE), nOldColor[0] = SetBkColor(hDC, GetNearestColor(hDC, (!bShape) ? m_nInteriorColor : VGA_COLOR_WHITE)), nOldColor[1] = SetTextColor(hDC, GetNearestColor(hDC, (!bShape) ? m_nHatchColor : VGA_COLOR_WHITE)); m_nStyle & MIMICSARCCTRL_TYPE_ARC; ) { Arc(hDC, pRect->left + m_nBorderSize / 2, pRect->top + m_nBorderSize / 2, pRect->right - m_nBorderSize / 2 - m_nBorderSize % 2, pRect->bottom - m_nBorderSize / 2 - m_nBorderSize % 2, ptRadial[0].x, ptRadial[0].y, ptRadial[1].x, ptRadial[1].y); break; } for (; m_nStyle & MIMICSARCCTRL_TYPE_PIE; ) { Pie(hDC, pRect->left + m_nBorderSize / 2, pRect->top + m_nBorderSize / 2, pRect->right - m_nBorderSize / 2 - m_nBorderSize % 2, pRect->bottom - m_nBorderSize / 2 - m_nBorderSize % 2, ptRadial[0].x, ptRadial[0].y, ptRadial[1].x, ptRadial[1].y); break; } for (; m_nStyle & MIMICSARCCTRL_TYPE_CHORD; ) { Chord(hDC, pRect->left + m_nBorderSize / 2, pRect->top + m_nBorderSize / 2, pRect->right - m_nBorderSize / 2 - m_nBorderSize % 2, pRect->bottom - m_nBorderSize / 2 - m_nBorderSize % 2, ptRadial[0].x, ptRadial[0].y, ptRadial[1].x, ptRadial[1].y); break; } SetBkMode(hDC, nMode); SetBkColor(hDC, nOldColor[0]); SetTextColor(hDC, nOldColor[1]); SelectObject(hDC, hOldBrush); } SelectObject(hDC, hOldPen); } DeleteObject(hInteriorBrush); } DeleteObject(hInteriorBitmap); } DeletePen(hBorderPen); } }
static bool rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style) { PLOT_LOG(("rectangle from %d,%d to %d,%d", x0, y0, x1, y1)); /* ensure the plot HDC is set */ if (plot_hdc == NULL) { LOG(("HDC not set on call to plotters")); return false; } HRGN clipregion = CreateRectRgnIndirect(&plot_clip); if (clipregion == NULL) { return false; } x1++; y1++; COLORREF pencol = (DWORD)(style->stroke_colour & 0x00FFFFFF); DWORD penstyle = PS_GEOMETRIC | (style->stroke_type == PLOT_OP_TYPE_DOT ? PS_DOT : (style->stroke_type == PLOT_OP_TYPE_DASH ? PS_DASH : (style->stroke_type == PLOT_OP_TYPE_NONE ? PS_NULL : 0))); LOGBRUSH lb = {BS_SOLID, pencol, 0}; LOGBRUSH lb1 = {BS_SOLID, style->fill_colour, 0}; if (style->fill_type == PLOT_OP_TYPE_NONE) lb1.lbStyle = BS_HOLLOW; HPEN pen = ExtCreatePen(penstyle, style->stroke_width, &lb, 0, NULL); if (pen == NULL) { return false; } HGDIOBJ penbak = SelectObject(plot_hdc, (HGDIOBJ) pen); if (penbak == NULL) { DeleteObject(pen); return false; } HBRUSH brush = CreateBrushIndirect(&lb1); if (brush == NULL) { SelectObject(plot_hdc, penbak); DeleteObject(pen); return false; } HGDIOBJ brushbak = SelectObject(plot_hdc, (HGDIOBJ) brush); if (brushbak == NULL) { SelectObject(plot_hdc, penbak); DeleteObject(pen); DeleteObject(brush); return false; } SelectClipRgn(plot_hdc, clipregion); Rectangle(plot_hdc, x0, y0, x1, y1); pen = SelectObject(plot_hdc, penbak); brush = SelectObject(plot_hdc, brushbak); SelectClipRgn(plot_hdc, NULL); DeleteObject(pen); DeleteObject(brush); DeleteObject(clipregion); return true; }