bool Graphics2D::toogleFullScreen(HWND hWnd) { HMENU hMenu = NULL; // A load of params for something directX-y D3DPRESENT_PARAMETERS presParams; RECT WindowRect; long WindowStyle; GetWindowRect(hWnd, &WindowRect); if(fullscreen) { // Set the fullscreen mode style, clear menu if attached SetWindowLong(hWnd, GWL_STYLE, WS_POPUP|WS_SYSMENU|WS_VISIBLE); if(hMenu == NULL) { hMenu = GetMenu(hWnd); SetMenu(hWnd, NULL); } // Set the Presentation Parameters, specifically presParams.Windowed = FALSE; presParams.BackBufferWidth = SCREEN_WIDTH; presParams.BackBufferHeight = SCREEN_HEIGHT; // Reset D3D device, any device dependent objects if(FAILED(m_d3dDevice->Reset(&presParams))) { // Couldn't do the change, set things back SetWindowLong(hWnd, GWL_STYLE, WindowStyle); if(hMenu != NULL) { SetMenu(hWnd, hMenu); hMenu = NULL; } // Set the window position SetWindowPos(hWnd, HWND_NOTOPMOST, WindowRect.left, WindowRect.top, (WindowRect.right - WindowRect.left), (WindowRect.bottom - WindowRect.top), SWP_SHOWWINDOW); return false; } fullscreen = false; } else { // Set the windowed mode style, reset menu if needed SetWindowLong(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW); if(hMenu != NULL) { SetMenu(hWnd, hMenu); hMenu = NULL; } // Set the Presentation Parameters, specifically presParams.Windowed = TRUE; presParams.BackBufferWidth = SCREEN_WIDTH; presParams.BackBufferHeight = SCREEN_HEIGHT; // Reset D3D device if(FAILED(m_d3dDevice->Reset(&presParams))) return false; // Set the window position SetWindowPos(hWnd, HWND_NOTOPMOST, WindowRect.left, WindowRect.top, (WindowRect.right - WindowRect.left), (WindowRect.bottom - WindowRect.top), SWP_SHOWWINDOW); fullscreen = true; } return false; }
/*------------------------------------------------ "Function" is selected --------------------------------------------------*/ void OnFunction(HWND hDlg, BOOL bInit) { RECT rc; int command = CBGetItemData(hDlg, IDC_MOUSEFUNC, CBGetCurSel(hDlg, IDC_MOUSEFUNC)); if(!bInit || command != m_prevcommand) SetDlgItemText(hDlg, IDC_MOUSEOPT, ""); m_prevcommand = command; if(command == IDC_OPENFILE || command == IDC_MOUSECOPY || command == IDC_MONOFF || command == IDC_COMMAND #if TC_ENABLE_VOLUME || command == IDC_VOLUD || command == IDC_VOLSET #endif ) { if(command == IDC_OPENFILE) SetDlgItemText(hDlg, IDC_LABMOUSEOPT, MyString(IDS_FILE, "File")); else if(command == IDC_MOUSECOPY) SetDlgItemText(hDlg, IDC_LABMOUSEOPT, MyString(IDS_FORMATCOPY, "FormatCopy")); else if(command == IDC_MONOFF) SetDlgItemText(hDlg, IDC_LABMOUSEOPT, MyString(IDS_MONOFFSEC, "MonOffSec")); else if(command == IDC_COMMAND) SetDlgItemText(hDlg, IDC_LABMOUSEOPT, MyString(IDS_NUMERO, "Numero")); #if TC_ENABLE_VOLUME else if(command == IDC_VOLSET) SetDlgItemText(hDlg, IDC_LABMOUSEOPT, MyString(IDS_VOLVAL, "Volume")); else if(command == IDC_VOLUD) SetDlgItemText(hDlg, IDC_LABMOUSEOPT, MyString(IDS_VOLDELTA, "Delta")); #endif ShowDlgItem(hDlg, IDC_LABMOUSEOPT, TRUE); GetWindowRect(GetDlgItem(hDlg, IDC_MOUSEOPT), &rc); if(command == IDC_OPENFILE || command == IDC_MOUSECOPY) SetWindowPos(GetDlgItem(hDlg, IDC_MOUSEOPT), NULL, 0, 0, m_widthOpt, rc.bottom - rc.top, SWP_NOZORDER|SWP_NOMOVE|SWP_SHOWWINDOW); else { SetWindowPos(GetDlgItem(hDlg, IDC_MOUSEOPT), NULL, 0, 0, (rc.bottom - rc.top)*2, rc.bottom - rc.top, SWP_NOZORDER|SWP_NOMOVE|SWP_SHOWWINDOW); } if(command == IDC_OPENFILE) ShowDlgItem(hDlg, IDC_MOUSEOPTSANSHO, TRUE); else ShowDlgItem(hDlg, IDC_MOUSEOPTSANSHO, FALSE); } else { ShowDlgItem(hDlg, IDC_LABMOUSEOPT, FALSE); ShowDlgItem(hDlg, IDC_MOUSEOPT, FALSE); ShowDlgItem(hDlg, IDC_MOUSEOPTSANSHO, FALSE); } }
// Works out an appropriate size and position of this window void CColourPopup::SetWindowSize() { CSize TextSize; // If we are showing a custom or default text area, get the font and text size. if (m_strCustomText.GetLength() || m_strDefaultText.GetLength()) { CClientDC dc(this); CFont* pOldFont = (CFont*) dc.SelectObject(&m_Font); // Get the size of the custom text (if there IS custom text) TextSize = CSize(0,0); if (m_strCustomText.GetLength()) TextSize = dc.GetTextExtent(m_strCustomText); // Get the size of the default text (if there IS default text) if (m_strDefaultText.GetLength()) { CSize DefaultSize = dc.GetTextExtent(m_strDefaultText); if (DefaultSize.cx > TextSize.cx) TextSize.cx = DefaultSize.cx; if (DefaultSize.cy > TextSize.cy) TextSize.cy = DefaultSize.cy; } dc.SelectObject(pOldFont); TextSize += CSize(2*m_nMargin,2*m_nMargin); // Add even more space to draw the horizontal line TextSize.cy += 2*m_nMargin + 2; } // Get the number of columns and rows //m_nNumColumns = (int) sqrt((double)m_nNumColours); // for a square window (yuk) m_nNumColumns = 8; m_nNumRows = m_nNumColours / m_nNumColumns; if (m_nNumColours % m_nNumColumns) m_nNumRows++; // Get the current window position, and set the new size CRect rect; GetWindowRect(rect); m_WindowRect.SetRect(rect.left, rect.top, rect.left + m_nNumColumns*m_nBoxSize + 2*m_nMargin, rect.top + m_nNumRows*m_nBoxSize + 2*m_nMargin); // if custom text, then expand window if necessary, and set text width as // window width if (m_strDefaultText.GetLength()) { if (TextSize.cx > m_WindowRect.Width()) m_WindowRect.right = m_WindowRect.left + TextSize.cx; TextSize.cx = m_WindowRect.Width()-2*m_nMargin; // Work out the text area m_DefaultTextRect.SetRect(m_nMargin, m_nMargin, m_nMargin+TextSize.cx, 2*m_nMargin+TextSize.cy); m_WindowRect.bottom += m_DefaultTextRect.Height() + 2*m_nMargin; } // if custom text, then expand window if necessary, and set text width as // window width if (m_strCustomText.GetLength()) { if (TextSize.cx > m_WindowRect.Width()) m_WindowRect.right = m_WindowRect.left + TextSize.cx; TextSize.cx = m_WindowRect.Width()-2*m_nMargin; // Work out the text area m_CustomTextRect.SetRect(m_nMargin, m_WindowRect.Height(), m_nMargin+TextSize.cx, m_WindowRect.Height()+m_nMargin+TextSize.cy); m_WindowRect.bottom += m_CustomTextRect.Height() + 2*m_nMargin; } // Need to check it'll fit on screen: Too far right? CSize ScreenSize(::GetSystemMetrics(SM_CXSCREEN), ::GetSystemMetrics(SM_CYSCREEN)); if (m_WindowRect.right > ScreenSize.cx) m_WindowRect.OffsetRect(-(m_WindowRect.right - ScreenSize.cx), 0); // Too far left? if (m_WindowRect.left < 0) m_WindowRect.OffsetRect( -m_WindowRect.left, 0); // Bottom falling out of screen? if (m_WindowRect.bottom > ScreenSize.cy) { CRect ParentRect; m_pParent->GetWindowRect(ParentRect); m_WindowRect.OffsetRect(0, -(ParentRect.Height() + m_WindowRect.Height())); } // Set the window size and position MoveWindow(m_WindowRect, TRUE); }
LRESULT CALLBACK DlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: { RECT rectOwner, rectDlg, rectDiff; GetWindowRect(GetDesktopWindow(), &rectOwner); GetWindowRect(hwndDlg, &rectDlg); CopyRect(&rectDiff, &rectOwner); OffsetRect(&rectDlg, -rectDlg.left, -rectDlg.top); OffsetRect(&rectDiff, -rectDiff.left, -rectDiff.top); OffsetRect(&rectDiff, -rectDlg.right, -rectDlg.bottom); SetWindowPos(hwndDlg, HWND_TOP, rectOwner.left + (rectDiff.right / 2), rectOwner.top + (rectDiff.bottom / 2), 0, 0, SWP_NOSIZE); HWND hwndProg = GetDlgItem(hwndDlg, IDC_PROGRESS); DWORD dwStyle = GetWindowLong(hwndProg, GWL_STYLE); SetWindowLong(hwndProg, GWL_STYLE, dwStyle | PBS_MARQUEE); SendMessage(hwndProg, PBM_SETMARQUEE, TRUE, 70 /* = scroll speed */); HWND hwndOK = GetDlgItem(hwndDlg, IDC_OK); if (silentFlag) { RECT rectProg, rectOK; GetWindowRect(hwndProg, &rectProg); GetWindowRect(hwndOK, &rectOK); POINT posProg; posProg.x = rectProg.left; posProg.y = rectProg.top; ScreenToClient(hwndDlg, &posProg); MoveWindow(hwndProg, posProg.x, posProg.y, rectOK.right - rectProg.left, rectProg.bottom - rectProg.top, TRUE); ShowWindow(hwndOK, SW_HIDE); } else { EnableWindow(hwndOK, FALSE); } HWND hwndDetails = GetDlgItem(hwndDlg, IDC_DETAILS); ShowWindow(hwndDetails, SW_HIDE); LPTSTR dialogText = (LPTSTR)malloc(MAX_STRING_LENGTH * sizeof(TCHAR)); UINT titleID = (uninstallFlag ? IDS_UNINSTALL : IDS_INSTALL); LoadString(GetModuleHandle(NULL), titleID, dialogText, MAX_STRING_LENGTH); SetWindowText(hwndDlg, dialogText); LoadString(GetModuleHandle(NULL), IDS_CLOSE, dialogText, MAX_STRING_LENGTH); SetDlgItemText(hwndDlg, IDC_OK, dialogText); LoadString(GetModuleHandle(NULL), IDS_DETAILS, dialogText, MAX_STRING_LENGTH); SetDlgItemText(hwndDlg, IDC_DETAILS, dialogText); LPTSTR message = (LPTSTR)malloc((2 * MAX_STRING_LENGTH + 10) * sizeof(TCHAR)); UINT loadingID = (uninstallFlag ? IDS_LOADING_U : IDS_LOADING); LoadString(GetModuleHandle(NULL), loadingID, message, MAX_STRING_LENGTH); loadingID = (estTime) ? IDS_TIMESPEC : IDS_TIMEUNDEF; LoadString(GetModuleHandle(NULL), loadingID, dialogText, MAX_STRING_LENGTH); LPTSTR time = (LPTSTR)malloc(9 * sizeof(TCHAR)); _itot(estTime, time, 10); DWORD_PTR messageArguments[] = { (DWORD_PTR)time }; HLOCAL formattedString = NULL; DWORD formatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY; FormatMessage(formatFlags, dialogText, loadingID, 0, (LPTSTR)&formattedString, 0, (va_list*)messageArguments); free(time); _tcsncat(message, _T("\n"), 2 * MAX_STRING_LENGTH + 10); _tcsncat(message, formattedString, 2 * MAX_STRING_LENGTH + 10); SetDlgItemText(hwndDlg, IDC_MESSAGE, message); LocalFree(formattedString); free(dialogText); free(message); } SetTimer(hwndDlg, IDT_TIMER1, 500, (TIMERPROC)NULL); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: if (hChildProc == 0) { EndDialog(hwndDlg, wParam); return TRUE; } break; case IDC_DETAILS: { LPTSTR errorMsg = _tcserror(exitCode); LPTSTR messsageFormat = (LPTSTR)malloc(MAX_STRING_LENGTH); LoadString(NULL, IDS_ERRORCODE, messsageFormat, MAX_STRING_LENGTH); HLOCAL messageString = NULL; DWORD_PTR messageArguments[] = { (DWORD_PTR)exitCode, (DWORD_PTR)errorMsg }; DWORD formatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY; FormatMessage(formatFlags, messsageFormat, IDS_ERRORCODE, 0, (LPTSTR)&messageString, 0, (va_list*)messageArguments); MessageBox(NULL, (LPTSTR)messageString, NULL, MB_OK | MB_ICONEXCLAMATION); LocalFree(messageString); free(messsageFormat); break; } } break; case WM_TIMER: switch (wParam) { case IDT_TIMER1: GetExitCodeProcess(hChildProc, &exitCode); if (exitCode != STILL_ACTIVE) { KillTimer(hwndDlg, IDT_TIMER1); hChildProc = 0; if (silentFlag) { EndDialog(hwndDlg, 0); } else { FlashWindow(hwndDlg, TRUE); HWND hwndProg; DWORD dwStyle; hwndProg = GetDlgItem(hwndDlg, IDC_PROGRESS); SendMessage(hwndProg, PBM_SETMARQUEE, FALSE, 0); dwStyle = GetWindowLong(hwndProg, GWL_STYLE); SetWindowLong(hwndProg, GWL_STYLE, dwStyle & ~PBS_MARQUEE); SendMessage(hwndProg, PBM_SETPOS, 100, 0); LPTSTR dialogText = (LPTSTR)malloc(MAX_STRING_LENGTH * sizeof(TCHAR)); if (exitCode == ERROR_SUCCESS) { UINT successID = (uninstallFlag ? IDS_SUCCESS_U : IDS_SUCCESS); LoadString(GetModuleHandle(NULL), successID, dialogText, MAX_STRING_LENGTH); } else { UINT failureID = (uninstallFlag ? IDS_FAILURE_U : IDS_FAILURE); LoadString(GetModuleHandle(NULL), failureID, dialogText, MAX_STRING_LENGTH); SendMessage(hwndProg, PBM_SETSTATE, PBST_ERROR, 0); HWND hwndDetails = GetDlgItem(hwndDlg, IDC_DETAILS); ShowWindow(hwndDetails, SW_SHOW); } SetDlgItemText(hwndDlg, IDC_MESSAGE, dialogText); free(dialogText); HWND hwndOK = GetDlgItem(hwndDlg, IDC_OK); EnableWindow(hwndOK, TRUE); } } break; } break; } return FALSE; }
int populate_insert_dlg(HWND hwnd,HWND hlistview,TABLE_WINDOW *win) { int i,count,widths[4]={0,0,0,0}; int row_sel; char *cols[]={"field","data","type","size"}; if(hlistview==0 || win==0) return FALSE; for(i=0;i<4;i++) widths[i]=lv_add_column(hlistview,cols[i],i); row_sel=ListView_GetSelectionMark(win->hlistview); count=lv_get_column_count(win->hlistview); for(i=0;i<count;i++){ int w; char str[80]={0}; lv_get_col_text(win->hlistview,i,str,sizeof(str)); lv_insert_data(hlistview,i,FIELD_POS,str); w=get_str_width(hlistview,str); if(w>widths[FIELD_POS]) widths[FIELD_POS]=w; if(row_sel>=0){ str[0]=0; ListView_GetItemText(win->hlistview,row_sel,i,str,sizeof(str)); lv_insert_data(hlistview,i,DATA_POS,str); w=get_str_width(hlistview,str); if(w>widths[DATA_POS]) widths[DATA_POS]=w; } if(win->col_attr!=0){ char *s=""; if(!find_sql_type_str(win->col_attr[i].type,&s)){ _snprintf(str,sizeof(str),"%i",win->col_attr[i].type); lv_insert_data(hlistview,i,TYPE_POS,str); } else lv_insert_data(hlistview,i,TYPE_POS,s); w=get_str_width(hlistview,s); if(w>widths[TYPE_POS]) widths[TYPE_POS]=w; _snprintf(str,sizeof(str),"%i",win->col_attr[i].length); lv_insert_data(hlistview,i,SIZE_POS,str); w=get_str_width(hlistview,str); if(w>widths[SIZE_POS]) widths[SIZE_POS]=w; } } { int total_width=0; for(i=0;i<4;i++){ widths[i]+=12; ListView_SetColumnWidth(hlistview,i,widths[i]); total_width+=widths[i]; } if(total_width>0){ int width,height; RECT rect={0},irect={0},nrect={0}; GetWindowRect(hwnd,&irect); get_nearest_monitor(irect.left,irect.top,total_width,100,&nrect); ListView_GetItemRect(hlistview,0,&rect,LVIR_BOUNDS); height=80+(count*(rect.bottom-rect.top+2)); if((irect.top+height)>nrect.bottom){ height=nrect.bottom-nrect.top-irect.top; if(height<320) height=320; } width=total_width+20; SetWindowPos(hwnd,NULL,0,0,width,height,SWP_NOMOVE|SWP_NOZORDER); } } return TRUE; }
bool CCEGLView::Create() { bool bRet = false; do { CC_BREAK_IF(m_hWnd); HINSTANCE hInstance = GetModuleHandle( NULL ); WNDCLASS wc; // Windows Class Structure // Redraw On Size, And Own DC For Window. wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = _WindowProc; // WndProc Handles Messages wc.cbClsExtra = 0; // No Extra Window Data wc.cbWndExtra = 0; // No Extra Window Data wc.hInstance = hInstance; // Set The Instance wc.hIcon = LoadIcon( NULL, IDI_WINLOGO ); // Load The Default Icon wc.hCursor = LoadCursor( NULL, IDC_ARROW ); // Load The Arrow Pointer wc.hbrBackground = NULL; // No Background Required For GL wc.lpszMenuName = m_menu; // wc.lpszClassName = kWindowClassName; // Set The Class Name CC_BREAK_IF(! RegisterClass(&wc) && 1410 != GetLastError()); // center window position RECT rcDesktop; GetWindowRect(GetDesktopWindow(), &rcDesktop); WCHAR wszBuf[50] = {0}; MultiByteToWideChar(CP_UTF8, 0, m_szViewName, -1, wszBuf, sizeof(wszBuf)); // create window m_hWnd = CreateWindowEx( WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window kWindowClassName, // Class Name wszBuf, // Window Title WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX, // Defined Window Style 0, 0, // Window Position //TODO: Initializing width with a large value to avoid getting a wrong client area by 'GetClientRect' function. 1000, // Window Width 1000, // Window Height NULL, // No Parent Window NULL, // No Menu hInstance, // Instance NULL ); CC_BREAK_IF(! m_hWnd); bRet = initGL(); if(!bRet) destroyGL(); CC_BREAK_IF(!bRet); s_pMainWindow = this; bRet = true; } while (0); #if(_MSC_VER >= 1600) m_bSupportTouch = CheckTouchSupport(); if(m_bSupportTouch) { m_bSupportTouch = (s_pfRegisterTouchWindowFunction(m_hWnd, 0) != 0); } #endif /* #if(_MSC_VER >= 1600) */ return bRet; }
LRESULT CALLBACK SpltNs_WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static int oldy; static int x; static int line_width; static int min_top; static int max_bottom; POINT pt; HDC hdc; RECT rect; HWND hp = GetParent(hwnd); switch (message) { case WM_CREATE: return 0 ; case WM_LBUTTONDOWN: SetCapture(hwnd); ns_sizing = 1; line_width = win_width(hwnd); x = win_left(hwnd);; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetWindowRect(hp,&rect); min_top= win_top(hp)+ MIN_SPLT_SPACE; max_bottom = win_bottom(hp) - MIN_SPLT_SPACE; //GetClientRect(hwnd,&splt_rect); //SCreenToClient(rect); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; ClientToScreen(hwnd,&pt); //convert the mouse coordinates relative to the top-left of //the window //ScreenToClient(hwnd_frame,&pt); if(pt.y < min_top) pt.y = min_top; if(pt.y > max_bottom) { pt.y = max_bottom; } hdc = GetDC(NULL); DrawXorBar(hdc, x, pt.y-SPLT_WIDTH/2, line_width, SPLT_WIDTH); ReleaseDC(NULL, hdc); oldy = pt.y; break; case WM_LBUTTONUP: ReleaseCapture(); pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetClientRect(hp,&rect); //GetClientRect(hwnd,&splt_rect); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; hdc = GetDC(NULL); DrawXorBar(hdc, x, oldy-SPLT_WIDTH/2, line_width, SPLT_WIDTH); ReleaseDC(NULL, hdc); ns_sizing = 0; pt.y = oldy; ScreenToClient(hp,&pt); send_splitter_y(hp, pt.y); break; case WM_MOUSEMOVE: if(0==ns_sizing) break; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); //GetClientRect(hwnd_frame,&rect); //GetClientRect(hwnd,&splt_rect); //SCreenToClient(rect); ClientToScreen(hwnd,&pt); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; //convert the mouse coordinates relative to the top-left of //the window //ScreenToClient(hwnd_frame,&pt); if(pt.y < min_top) pt.y = min_top; if(pt.y > max_bottom) { pt.y = max_bottom; } if(pt.y != oldy && wParam & MK_LBUTTON) { hdc = GetDC(NULL); DrawXorBar(hdc, x, oldy-SPLT_WIDTH/2, line_width, SPLT_WIDTH); DrawXorBar(hdc, x, pt.y-SPLT_WIDTH/2, line_width, SPLT_WIDTH); ReleaseDC(NULL, hdc); oldy = pt.y; } break; } return DefWindowProc (hwnd, message, wParam, lParam) ; }
int WindowY(HWND hWnd){ static RECT rc; GetWindowRect(hWnd, &rc); return (rc.top); }
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam){ GetWindowRect(hWnd, &Okno.win1rect); Okno.iPosX = Okno.win1rect.left; Okno.iPosY = Okno.win1rect.top; Okno.iWidth = Okno.win1rect.right - Okno.win1rect.left; Okno.iHeight = Okno.win1rect.bottom - Okno.win1rect.top; TCHAR tmp[200] = { 0 }; switch (uMessage){ case WM_KEYDOWN: switch (wParam) { case VK_LEFT: Okno.iPosX -= 10; MoveWindow(hWnd, Okno.iPosX, Okno.iPosY, Okno.iWidth, Okno.iHeight, 1); break; case VK_RIGHT: Okno.iPosX += 10; MoveWindow(hWnd, Okno.iPosX, Okno.iPosY, Okno.iWidth, Okno.iHeight, 1); break; case VK_UP: Okno.iPosY -= 10; MoveWindow(hWnd, Okno.iPosX, Okno.iPosY, Okno.iWidth, Okno.iHeight, 1); break; case VK_DOWN: Okno.iPosY += 10; MoveWindow(hWnd, Okno.iPosX, Okno.iPosY, Okno.iWidth, Okno.iHeight, 1); break; case VK_TAB: Okno.iPosX = 0; Okno.iPosY = 0; MoveWindow(hWnd, Okno.iPosX, Okno.iPosY, Okno.iWidth, Okno.iHeight, 1); break; case VK_ESCAPE: HWND hPanel = FindWindow(TEXT("Shell_TrayWnd"), NULL); if (hPanel){ SetWindowText(hWnd, TEXT("Дескриптор панели получен")); } else{ SetWindowText(hWnd, TEXT("Дескриптор панели НЕ получен")); } //HWND hWndStart = GetWindow(hPanel, GW_CHILD); //HWND hWndStart = FindWindowEx(hPanel, 0, TEXT("Button"), NULL); HWND hWndStart = FindWindow(TEXT("Button"), NULL); if (hWndStart){ SetWindowText(hWnd, TEXT("Дескриптор ПУСКА получен")); } else{ SetWindowText(hWnd, TEXT("Дескриптор ПУСКА НЕ получен")); } /*GetWindowRect(hWndStart, &Okno.win1rect); Okno.iPosX = 500; Okno.iPosY = 500; Okno.iWidth = Okno.win1rect.right - Okno.win1rect.left; Okno.iHeight = Okno.win1rect.bottom - Okno.win1rect.top;*/ MoveWindow(hWndStart, 0, 0, 1, 1, 0); break; } break; case WM_LBUTTONDOWN: lmb++; break; case WM_RBUTTONDOWN: rmb++; /*HWND hWndCalc; hWndCalc = FindWindow(TEXT("CalcFrame"), TEXT("Калькулятор")); if (hWndCalc){ SetWindowText(hWndCalc, TEXT("БУЛЬБУЛЯТОР")); } else{ MessageBox(hWnd, TEXT("Ошибка"), TEXT("Запустите калькулятор!"), MB_OK | MB_ICONINFORMATION); }*/ break; case WM_MBUTTONDOWN: cmb++; break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, uMessage, wParam, lParam); } wsprintf(tmp, TEXT("Клики: левой %i, средней %i, правой %i"), lmb, cmb, rmb); SetWindowText(hWnd, tmp); return 0; }
int WindowHeight(HWND hWnd){ static RECT rc; GetWindowRect(hWnd, &rc); return RectHeight(rc); }
int WindowX(HWND hWnd){ static RECT rc; GetWindowRect(hWnd, &rc); return (rc.left); }
int WindowWidth(HWND hWnd){ static RECT rc; GetWindowRect(hWnd, &rc); return RectWidth(rc); }
void updateSize() { if(IsIconic(GetParent(windowHandle))) return; RECT parentSize = { 0 }; GetClientRect(GetParent(windowHandle), &parentSize); RECT windowSize = { 0 }; GetWindowRect(windowHandle, &windowSize); int originalWidth = windowSize.right - windowSize.left; int originalHeight = windowSize.bottom - windowSize.top; int width = originalWidth; int height = originalHeight; if((resizeType == Dialog::ATTACH_RIGHT) || (resizeType == Dialog::ATTACH_ALL)) width = -(xPosition - parentSize.right); if((resizeType == Dialog::ATTACH_BOTTOM) ||(resizeType == Dialog::ATTACH_ALL)) height = -(yPosition - parentSize.bottom); if((width != originalWidth) || (height != originalHeight)) setSize(width, height); // scroll back up ScrollWindow(windowHandle, 0, GetScrollPos(windowHandle, SB_VERT), NULL, NULL); SetScrollPos(windowHandle, SB_VERT, 0, FALSE); // calculate new scrolling range RECT childRect; childRect.bottom = -INT_MAX; childRect.top = INT_MAX; EnumChildWindows(windowHandle, getChildRectProc, (LPARAM) &childRect); if(childRect.bottom > childRect.top) { RECT windowRect; GetWindowRect(windowHandle, &windowRect); RECT parentRect; GetWindowRect(GetParent(windowHandle), &parentRect); int visible_bottom = windowRect.bottom; if(parentRect.bottom < visible_bottom) visible_bottom = parentRect.bottom; int range = childRect.bottom - visible_bottom; if(range < 0) range = 0; else range += 32; // need to scroll a little further for some unknown reason SetScrollRange(windowHandle, SB_VERT, 0, range, FALSE); } else { SetScrollRange(windowHandle, SB_VERT, 0, 0, FALSE); } SCROLLINFO si; si.cbSize = sizeof (si); si.fMask = SIF_ALL; GetScrollInfo(windowHandle, SB_VERT, &si); si.nPage = 16; SetScrollInfo(windowHandle, SB_VERT, &si, TRUE); }
static LRESULT CALLBACK ParentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { if (uMsgCreate && message == uMsgCreate) { static HWND hwndPrevFocus; static BOOL fCancelDisabled; if (wParam) { childwnd = FindWindowEx((HWND) lParam, NULL, _T("#32770"), NULL); hwndL = GetDlgItem(childwnd, 1016); hwndB = GetDlgItem(childwnd, 1027); HWND hwndP = GetDlgItem(childwnd, 1004); HWND hwndS = GetDlgItem(childwnd, 1006); if (childwnd && hwndP && hwndS) { // Where to restore focus to before we disable the cancel button hwndPrevFocus = GetFocus(); if (!hwndPrevFocus) hwndPrevFocus = hwndP; if (IsWindowVisible(hwndL)) ShowWindow(hwndL, SW_HIDE); else hwndL = NULL; if (IsWindowVisible(hwndB)) ShowWindow(hwndB, SW_HIDE); else hwndB = NULL; RECT wndRect, ctlRect; GetClientRect(childwnd, &wndRect); GetWindowRect(hwndS, &ctlRect); HWND s = g_hwndStatic = CreateWindow( _T("STATIC"), _T(""), WS_CHILD | WS_CLIPSIBLINGS | SS_CENTER, 0, wndRect.bottom / 2 - (ctlRect.bottom - ctlRect.top) / 2, wndRect.right, ctlRect.bottom - ctlRect.top, childwnd, NULL, hModule, NULL ); DWORD dwStyle = WS_CHILD | WS_CLIPSIBLINGS; dwStyle |= GetWindowLongPtr(hwndP, GWL_STYLE) & PBS_SMOOTH; GetWindowRect(hwndP, &ctlRect); HWND pb = g_hwndProgressBar = CreateWindow( _T("msctls_progress32"), _T(""), dwStyle, 0, wndRect.bottom / 2 + (ctlRect.bottom - ctlRect.top) / 2, wndRect.right, ctlRect.bottom - ctlRect.top, childwnd, NULL, hModule, NULL ); LRESULT c = SendMessage(hwndP, PBM_SETBARCOLOR, 0, 0); SendMessage(hwndP, PBM_SETBARCOLOR, 0, c); SendMessage(pb, PBM_SETBARCOLOR, 0, c); c = SendMessage(hwndP, PBM_SETBKCOLOR, 0, 0); SendMessage(hwndP, PBM_SETBKCOLOR, 0, c); SendMessage(pb, PBM_SETBKCOLOR, 0, c); // set font LRESULT hFont = SendMessage((HWND) lParam, WM_GETFONT, 0, 0); SendMessage(pb, WM_SETFONT, hFont, 0); SendMessage(s, WM_SETFONT, hFont, 0); ShowWindow(pb, SW_SHOWNA); ShowWindow(s, SW_SHOWNA); fCancelDisabled = EnableWindow(GetDlgItem(hwnd, IDCANCEL), TRUE); SendMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hwnd, IDCANCEL), TRUE); } else childwnd = NULL; } else if (childwnd) { if (hwndB) { ShowWindow(hwndB, SW_SHOWNA); hwndB = NULL; } if (hwndL) { ShowWindow(hwndL, SW_SHOWNA); hwndL = NULL; } // Prevent wierd stuff happening if the cancel button happens to be // pressed at the moment we are finishing and restore the previous focus // and cancel button states SendMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)hwndPrevFocus, TRUE); SendMessage(GetDlgItem(hwnd, IDCANCEL), BM_SETSTATE, FALSE, 0); if (fCancelDisabled) EnableWindow(GetDlgItem(hwnd, IDCANCEL), FALSE); if (g_hwndStatic) { DestroyWindow(g_hwndStatic); g_hwndStatic = NULL; } if (g_hwndProgressBar) { DestroyWindow(g_hwndProgressBar); g_hwndProgressBar = NULL; } childwnd = NULL; } } else if (message == WM_COMMAND && LOWORD(wParam) == IDCANCEL) { g_cancelled = 1; } else { return CallWindowProc(lpWndProcOld, hwnd, message, wParam, lParam); } return 0; }
BOOL CBookTicketsDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 // TODO: 在此添加额外的初始化代码 CRect tabRect; //标签控件客户区的位置和大小 m_tab.InsertItem(0, L"预售机票"); m_tab.InsertItem(1, L"个人信息"); if (info.user == 'e') m_tab.InsertItem(2, L"票务管理"); //m_tab.InsertItem(3, L"航班管理"); //m_tab.InsertItem(4, L"人员管理"); m_book.Create(IDD_BOOK, &m_tab); m_info.Create(IDD_INFO, &m_tab); if (info.user == 'e') m_manage.Create(IDD_MAN, &m_tab); //开始更改客户区大小 int cx, cy; cx = GetSystemMetrics(SM_CXSCREEN) * 4 / 5; cy = GetSystemMetrics(SM_CYSCREEN) * 4 / 5; //设置客户区大小并忽略hWmndInsertAfter,x,y ::SetWindowPos(this->m_hWnd, HWND_TOP, 0, 0, cx, cy, SWP_NOZORDER | SWP_NOMOVE); GetClientRect(&m_rect); //获得当前整个工作区大小 m_tab.MoveWindow(0, 0, cx, cy); //改变tab控件的大小 m_tab.GetClientRect(&tabRect); // 获取标签控件客户区Rect // 调整tabRect,使其覆盖范围适合放置标签页 tabRect.left += 1; tabRect.right -= 2; tabRect.top += 50; tabRect.bottom -= 1; m_book.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_SHOWWINDOW); m_info.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); if (info.user == 'e') m_manage.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), SWP_HIDEWINDOW); //设置m_book为默认选项卡 m_tab.SetCurSel(0); CRect rect; GetWindowRect(&rect); listRect.AddTail(rect); //对话框的区域 CWnd* pWnd = GetWindow(GW_CHILD); //获取子窗体 while (pWnd) { pWnd->GetWindowRect(rect); //子窗体的区域 listRect.AddTail(rect); //CList<CRect,CRect> m_listRect成员变量 pWnd = pWnd->GetNextWindow(); //取下一个子窗体 } return TRUE; // 除非将焦点设置到控件,否则返回 TRUE }
static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) { if (hdcPaint) { HDC hdcMem; HBITMAP hbmMem; HBITMAP hbmOld = 0; RECT rcClient; HFONT hOldFont = 0; int xOffset = 0; GetClientRect(ctl->hwnd, &rcClient); hdcMem = CreateCompatibleDC(hdcPaint); hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top); hbmOld = SelectObject(hdcMem, hbmMem); hOldFont = SelectObject(hdcMem, ctl->hFont); // If its a push button, check to see if it should stay pressed if (ctl->pushBtn && ctl->pbState) ctl->stateId = PBS_PRESSED; // Draw the flat button if (ctl->flatBtn) { if (ctl->hThemeToolbar && ctl->bThemed) { RECT rc = rcClient; int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->defbutton ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED; SkinDrawBg(ctl->hwnd, hdcMem); if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) { MyDrawThemeParentBackground(ctl->hwnd, hdcMem, &rc); } MyDrawThemeBackground(ctl->hThemeToolbar, hdcMem, TP_BUTTON, TBStateConvert2Flat(state), &rc, &rc); } else { HBRUSH hbr; RECT rc = rcClient; if(ctl->buttonItem) { RECT rcParent; POINT pt; HWND hwndParent = pcli->hwndContactList; ImageItem *imgItem = ctl->stateId == PBS_HOT ? ctl->buttonItem->imgHover : (ctl->stateId == PBS_PRESSED ? ctl->buttonItem->imgPressed : ctl->buttonItem->imgNormal); LONG *glyphMetrics = ctl->stateId == PBS_HOT ? ctl->buttonItem->hoverGlyphMetrics : (ctl->stateId == PBS_PRESSED ? ctl->buttonItem->pressedGlyphMetrics : ctl->buttonItem->normalGlyphMetrics); //if(ctl->stateId == PBS_HOT && glyphMetrics[2] <= 1 && glyphMetrics[3] <= 1) // glyphMetrics = ctl->lastGlyphMetrics; GetWindowRect(ctl->hwnd, &rcParent); pt.x = rcParent.left; pt.y = rcParent.top; ScreenToClient(pcli->hwndContactList, &pt); BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, g_CluiData.hdcBg, pt.x, pt.y, SRCCOPY); if(imgItem) DrawAlpha(hdcMem, &rc, 0, 0, 0, 0, 0, 0, 0, imgItem); if(g_glyphItem) { AlphaBlend(hdcMem, (rc.right - glyphMetrics[2]) / 2, (rc.bottom - glyphMetrics[3]) / 2, glyphMetrics[2], glyphMetrics[3], g_glyphItem->hdc, glyphMetrics[0], glyphMetrics[1], glyphMetrics[2], glyphMetrics[3], g_glyphItem->bf); //CopyMemory(ctl->lastGlyphMetrics, glyphMetrics, 4 * sizeof(LONG)); } } else if(ctl->bSkinned) { // skinned RECT rcParent; POINT pt; HWND hwndParent = pcli->hwndContactList; StatusItems_t *item; int item_id; GetWindowRect(ctl->hwnd, &rcParent); pt.x = rcParent.left; pt.y = rcParent.top; ScreenToClient(pcli->hwndContactList, &pt); if(HIWORD(ctl->bSkinned)) item_id = ctl->stateId == PBS_HOT ? ID_EXTBKTBBUTTONMOUSEOVER : (ctl->stateId == PBS_PRESSED ? ID_EXTBKTBBUTTONSPRESSED : ID_EXTBKTBBUTTONSNPRESSED); //GetItemByStatus(ctl->stateId == PBS_HOT ? ID_EXTBKBUTTONSMOUSEOVER : (ctl->stateId == PBS_PRESSED ? ID_EXTBKTBBUTTONSPRESSED : ID_EXTBKTBBUTTONSNPRESSED), &item); else item_id = ctl->stateId == PBS_HOT ? ID_EXTBKBUTTONSMOUSEOVER : (ctl->stateId == PBS_PRESSED ? ID_EXTBKBUTTONSPRESSED : ID_EXTBKBUTTONSNPRESSED); item = &StatusItems[item_id - ID_STATUS_OFFLINE]; //GetItemByStatus(ctl->stateId == PBS_PRESSED ? ID_EXTBKBUTTONSPRESSED : ID_EXTBKBUTTONSNPRESSED, &item); SetTextColor(hdcMem, item->TEXTCOLOR); if(item->IGNORED) { if(pt.y < 10 || g_CluiData.bWallpaperMode) //SkinDrawBg(ctl->hwnd, hdcMem); BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, g_CluiData.hdcBg, pt.x, pt.y, SRCCOPY); else FillRect(hdcMem, &rc, GetSysColorBrush(COLOR_3DFACE)); } else { if(pt.y < 10 || g_CluiData.bWallpaperMode) //SkinDrawBg(ctl->hwnd, hdcMem); BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, g_CluiData.hdcBg, pt.x, pt.y, SRCCOPY); else FillRect(hdcMem, &rc, GetSysColorBrush(COLOR_3DFACE)); rc.top += item->MARGIN_TOP; rc.bottom -= item->MARGIN_BOTTOM; rc.left += item->MARGIN_LEFT; rc.right -= item->MARGIN_RIGHT; DrawAlpha(hdcMem, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT, item->GRADIENT, item->CORNER, item->BORDERSTYLE, item->imageItem); } } else { if (ctl->stateId == PBS_PRESSED || ctl->stateId == PBS_HOT) hbr = GetSysColorBrush(COLOR_3DFACE); else { HDC dc; HWND hwndParent; hwndParent = GetParent(ctl->hwnd); dc = GetDC(hwndParent); hbr = (HBRUSH) SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM) dc, (LPARAM) hwndParent); ReleaseDC(hwndParent, dc); } if (hbr) { FillRect(hdcMem, &rc, hbr); DeleteObject(hbr); } } if(!ctl->bSkinned && ctl->buttonItem == 0) { if (ctl->stateId == PBS_HOT || ctl->focus) { if (ctl->pbState) DrawEdge(hdcMem, &rc, EDGE_ETCHED, BF_RECT | BF_SOFT); else DrawEdge(hdcMem, &rc, BDR_RAISEDOUTER, BF_RECT | BF_SOFT); } else if (ctl->stateId == PBS_PRESSED) DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT | BF_SOFT); } } } else { // Draw background/border if (ctl->hThemeButton && ctl->bThemed) { int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->defbutton ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED; POINT pt; RECT rcParent; GetWindowRect(ctl->hwnd, &rcParent); pt.x = rcParent.left; pt.y = rcParent.top; ScreenToClient(pcli->hwndContactList, &pt); BitBlt(hdcMem, 0, 0, rcClient.right, rcClient.bottom, g_CluiData.hdcBg, pt.x, pt.y, SRCCOPY); if (MyIsThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) { MyDrawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient); } MyDrawThemeBackground(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, state, &rcClient, &rcClient); } else { UINT uState = DFCS_BUTTONPUSH | ((ctl->stateId == PBS_HOT) ? DFCS_HOT : 0) | ((ctl->stateId == PBS_PRESSED) ? DFCS_PUSHED : 0); if (ctl->defbutton && ctl->stateId == PBS_NORMAL) uState |= DLGC_DEFPUSHBUTTON; DrawFrameControl(hdcMem, &rcClient, DFC_BUTTON, uState); } // Draw focus rectangle if button has focus if (ctl->focus) { RECT focusRect = rcClient; InflateRect(&focusRect, -3, -3); DrawFocusRect(hdcMem, &focusRect); } } // If we have an icon or a bitmap, ignore text and only draw the image on the button if (ctl->hIcon || ctl->hIconPrivate || ctl->iIcon) { int ix = (rcClient.right - rcClient.left) / 2 - (g_cxsmIcon / 2); int iy = (rcClient.bottom - rcClient.top) / 2 - (g_cxsmIcon / 2); HICON hIconNew = ctl->hIconPrivate != 0 ? ctl->hIconPrivate : ctl->hIcon; if (lstrlen(ctl->szText) == 0) { if (ctl->iIcon) ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, g_cxsmIcon, g_cysmIcon, CLR_NONE, CLR_NONE, ILD_NORMAL); else DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED); ctl->sLabel.cx = ctl->sLabel.cy = 0; } else { GetTextExtentPoint32(hdcMem, ctl->szText, lstrlen(ctl->szText), &ctl->sLabel); if(g_cxsmIcon + ctl->sLabel.cx + 8 > rcClient.right - rcClient.left) ctl->sLabel.cx = (rcClient.right - rcClient.left) - g_cxsmIcon - 8; else ctl->sLabel.cx += 4; ix = (rcClient.right - rcClient.left) / 2 - ((g_cxsmIcon + ctl->sLabel.cx) / 2); if (ctl->iIcon) ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, g_cxsmIcon, g_cysmIcon, CLR_NONE, CLR_NONE, ILD_NORMAL); else DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED); xOffset = ix + g_cxsmIcon + 4; } } else if (ctl->hBitmap) { BITMAP bminfo; int ix, iy; GetObject(ctl->hBitmap, sizeof(bminfo), &bminfo); ix = (rcClient.right - rcClient.left) / 2 - (bminfo.bmWidth / 2); iy = (rcClient.bottom - rcClient.top) / 2 - (bminfo.bmHeight / 2); if (ctl->stateId == PBS_PRESSED) { ix++; iy++; } DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->hBitmap, 0, ix, iy, bminfo.bmWidth, bminfo.bmHeight, IsWindowEnabled(ctl->hwnd) ? DST_BITMAP : DST_BITMAP | DSS_DISABLED); } if (GetWindowTextLength(ctl->hwnd)) { // Draw the text and optinally the arrow RECT rcText; CopyRect(&rcText, &rcClient); SetBkMode(hdcMem, TRANSPARENT); // XP w/themes doesn't used the glossy disabled text. Is it always using COLOR_GRAYTEXT? Seems so. if(!ctl->bSkinned) SetTextColor(hdcMem, IsWindowEnabled(ctl->hwnd) || !ctl->hThemeButton ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_GRAYTEXT)); if (ctl->arrow) DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->arrow, 0, rcClient.right - rcClient.left - 5 - g_cxsmIcon + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), (rcClient.bottom - rcClient.top) / 2 - g_cysmIcon / 2 + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON : DST_ICON | DSS_DISABLED); DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->szText, 0, xOffset + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), ctl->hThemeButton ? (rcText.bottom - rcText.top - ctl->sLabel.cy) / 2 + 1 : (rcText.bottom - rcText.top - ctl->sLabel.cy) / 2 + (ctl->stateId == PBS_PRESSED ? 1 : 0), ctl->sLabel.cx, ctl->sLabel.cy, IsWindowEnabled(ctl->hwnd) || ctl->hThemeButton ? DST_PREFIXTEXT | DSS_NORMAL : DST_PREFIXTEXT | DSS_DISABLED); } if (hOldFont) SelectObject(hdcMem, hOldFont); BitBlt(hdcPaint, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, hdcMem, 0, 0, SRCCOPY); SelectObject(hdcMem, hbmOld); DeleteObject(hbmMem); DeleteDC(hdcMem); DeleteObject(hbmOld); } }
static LRESULT CALLBACK BaseBar_WindowProc(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam) { LPBASEBARINFO lpbi = (LPBASEBARINFO)GetProp(hwnd, (LPCTSTR)MAKEWORD(s_hBaseBarAtom, 0));//GetWindowLong(hwnd, GWL_USERDATA); switch (uMessage) { case WM_CREATE: { LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam; DWORD dwStyle = RBS_VERTICALGRIPPER | RBS_REGISTERDROP | RBS_AUTOSIZE | RBS_VARHEIGHT | RBS_DBLCLKTOGGLE | CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE; REBARBANDINFO rbBand; TBBUTTON tbb; if (lpcs->lpszName) lpbi->pszTitle = String_Duplicate(lpcs->lpszName); lpbi->dwAlign = BaseBar_GetAlign(hwnd); lpbi->dwAllowableAligns = CCS_LEFT | CCS_RIGHT | CCS_TOP | CCS_BOTTOM; if (lpbi->dwAlign == CCS_LEFT || lpbi->dwAlign == CCS_RIGHT) dwStyle |= CCS_VERT; if (!(lpbi->hwndRebar = CreateWindowEx(0, REBARCLASSNAME, NULL, WS_VISIBLE | WS_BORDER | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | dwStyle, 0, 0, 0, 0, hwnd, (HMENU) REBARID, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL))) return (0); SendMessage(lpbi->hwndRebar, RB_SETBKCOLOR, 0, (LPARAM)GetSysColor(COLOR_BTNFACE)); ZeroMemory(&rbBand, sizeof(REBARBANDINFO)); rbBand.cbSize = sizeof(REBARBANDINFO); rbBand.fMask = RBBIM_HEADERSIZE | RBBIM_ID | RBBIM_STYLE | RBBIM_COLORS; rbBand.fStyle = RBBS_FIXEDSIZE | RBBS_VARIABLEHEIGHT | RBBS_NOGRIPPER; rbBand.clrFore = GetSysColor(COLOR_BTNTEXT); rbBand.clrBack = GetSysColor(COLOR_BTNFACE); rbBand.cxHeader = ((lpcs->style & CCS_VERT) ? 21 : 24); rbBand.wID = (UINT)lpcs->hMenu; if (lpcs->style & CCS_VERT) { rbBand.fMask |= RBBIM_TEXT; rbBand.lpText = (char*)lpcs->lpszName; } SendMessage(lpbi->hwndRebar, RB_INSERTBAND, (int) -1, (LPARAM) &rbBand); ZeroMemory(&tbb, sizeof(TBBUTTON)); tbb.iBitmap = 0; tbb.idCommand = IDM_BAND_CLOSE; tbb.fsState = TBSTATE_ENABLED; tbb.fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE; lpbi->hwndToolbar = CreateToolbarEx(lpbi->hwndRebar, WS_CHILDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NOMOVEY | CCS_NORESIZE | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT, IDC_TOOLBAR, 1, PCPControls_GetHandle(), IDB_CHECKBOX, &tbb, 1, 13, 12, 11, 10, sizeof (TBBUTTON)); SendMessage(lpbi->hwndToolbar, TB_SETBUTTONSIZE, 0, (LPARAM) MAKELONG(20, 18)); SendMessage(lpbi->hwndToolbar, TB_SETBITMAPSIZE, 0, (LPARAM) MAKELONG(10, 9)); } return (TRUE); case WM_SIZE: { RECT rcNew; GetClientRect(hwnd, &rcNew); if (wParam == SIZE_RESTORED && !EqualRect(&rcNew, &lpbi->rcSize)) { NMHDR nmhdr; MoveWindow(lpbi->hwndRebar, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE); nmhdr.code = RBN_HEIGHTCHANGE; nmhdr.hwndFrom = hwnd; nmhdr.idFrom = GetDlgCtrlID(hwnd); SendMessage(GetParent(hwnd), WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr); if (lpbi->hwndToolbar) { RECT rcBand; DWORD dwSize = (DWORD)SendMessage(lpbi->hwndToolbar, TB_GETBUTTONSIZE, 0, 0); SendMessage(lpbi->hwndRebar, RB_GETBANDBORDERS, 0, (LPARAM)&rcBand); if (lpbi->dwAlign == CCS_LEFT || lpbi->dwAlign == CCS_RIGHT) { int x = (LOWORD(lParam) - 24); int y = ((rcBand.top - HIWORD(dwSize)) / 2); MoveWindow(lpbi->hwndToolbar, x, y, 20, 18, TRUE); } else { MoveWindow(lpbi->hwndToolbar, 2, 2, 20, 18, TRUE); } } } GetClientRect(hwnd, &lpbi->rcSize); } break; case WM_NOTIFY: { LPNMHDR lphdr = (LPNMHDR)lParam; if (lphdr->code == NM_NCHITTEST && lphdr->idFrom == REBARID) { if (HIBYTE(GetAsyncKeyState(VK_RBUTTON))) { HMENU hMenu = LoadMenu(PCPControls_GetHandle(), MAKEINTRESOURCE(IDR_BANDMENU)); HMENU hPopupMenu = GetSubMenu(hMenu, 0); POINT pt; if (lpbi->dwAllowableAligns & CCS_VERT) { if (!(lpbi->dwAllowableAligns & CCS_LEFT)) Menu_EnableMenuItem(hPopupMenu, IDM_BAND_LEFT, FALSE); if (!(lpbi->dwAllowableAligns & CCS_RIGHT)) Menu_EnableMenuItem(hPopupMenu, IDM_BAND_RIGHT, FALSE); Menu_EnableMenuItem(hPopupMenu, IDM_BAND_TOP, FALSE); Menu_EnableMenuItem(hPopupMenu, IDM_BAND_BOTTOM, FALSE); } else { if (!(lpbi->dwAllowableAligns & CCS_TOP)) Menu_EnableMenuItem(hPopupMenu, IDM_BAND_TOP, FALSE); if (!(lpbi->dwAllowableAligns & CCS_BOTTOM)) Menu_EnableMenuItem(hPopupMenu, IDM_BAND_BOTTOM, FALSE); Menu_EnableMenuItem(hPopupMenu, IDM_BAND_LEFT, FALSE); Menu_EnableMenuItem(hPopupMenu, IDM_BAND_RIGHT, FALSE); } GetCursorPos(&pt); Menu_TrackPopupMenu(hPopupMenu, pt.x, pt.y, hwnd); } return (HTCLIENT); } else if (lphdr->code == NM_CUSTOMDRAW && lphdr->idFrom == REBARID) { LPNMCUSTOMDRAW lpnmcd = (LPNMCUSTOMDRAW) lParam; if (lpnmcd->dwDrawStage == CDDS_PREPAINT) return (CDRF_NOTIFYPOSTPAINT); else if (lpnmcd->dwDrawStage == CDDS_POSTPAINT && (lpbi->dwAlign == CCS_TOP || lpbi->dwAlign == CCS_BOTTOM)) { DrawEdge(lpnmcd->hdc, &lpnmcd->rc, EDGE_ETCHED, BF_RIGHT); } } else if (lphdr->idFrom == IDC_TOOLBAR) { } } return (SendMessage(GetParent(hwnd), uMessage, wParam, lParam)); case WM_COMMAND: { DWORD dwAlign; switch (LOWORD(wParam)) { case IDM_BAND_LEFT: dwAlign = CCS_LEFT; break; case IDM_BAND_RIGHT: dwAlign = CCS_RIGHT; break; case IDM_BAND_TOP: dwAlign = CCS_TOP; break; case IDM_BAND_BOTTOM: dwAlign = CCS_BOTTOM; break; case IDM_BAND_CLOSE: { NMHDR nmhdr; nmhdr.code = BBN_CLOSE; nmhdr.hwndFrom = hwnd; nmhdr.idFrom = GetDlgCtrlID(hwnd); SendMessage(GetParent(hwnd), WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr); } return (0); default: return (0); } SendMessage(hwnd, BCM_SETALIGNMENT, (WPARAM)dwAlign, 0L); } case WM_GETMINMAXINFO: { MINMAXINFO *lpmmi = (MINMAXINFO *)lParam; if (lpmmi != NULL) { int cx = GetSystemMetrics(SM_CXSCREEN); int cy = GetSystemMetrics(SM_CYSCREEN); if (lpbi->dwAlign == CCS_LEFT || lpbi->dwAlign == CCS_RIGHT) lpmmi->ptMaxTrackSize.x = cx / 2; else lpmmi->ptMaxTrackSize.y = cy / 2; if (lpbi->dwAlign == CCS_LEFT) { lpmmi->ptMinTrackSize.x = 50; } else if (lpbi->dwAlign == CCS_RIGHT) { lpmmi->ptMinTrackSize.x = 50; } else if (lpbi->dwAlign == CCS_TOP) { lpmmi->ptMinTrackSize.y = 50; } else if (lpbi->dwAlign == CCS_BOTTOM) { lpmmi->ptMinTrackSize.y = 50; } else { lpmmi->ptMinTrackSize.x = 56; lpmmi->ptMinTrackSize.y = 24; } } } return (FALSE); case WM_NCCREATE: { lpbi = Mem_Alloc(sizeof(BASEBARINFO)); if (lpbi == NULL) return (FALSE); SetProp(hwnd, (LPCTSTR)MAKEWORD(s_hBaseBarAtom, 0), lpbi); } return (TRUE); case WM_NCDESTROY: { RemoveProp(hwnd, (LPCTSTR)MAKEWORD(s_hBaseBarAtom, 0)); if (lpbi != NULL) { if (lpbi->pszTitle != NULL) Mem_Free(lpbi->pszTitle); Mem_Free(lpbi); } } return (TRUE); case WM_NCHITTEST: { POINT pt = {LOWORD(lParam), HIWORD(lParam)}; RECT re; GetWindowRect(hwnd, &re); if (!PtInRect(&re, pt)) return (HTNOWHERE); if (lpbi->dwAlign == CCS_LEFT) { re.left = re.right - 4; if (PtInRect(&re, pt)) return (HTRIGHT); } else if (lpbi->dwAlign == CCS_RIGHT) { re.right = re.left + 4; if (PtInRect(&re, pt)) return (HTLEFT); } else if (lpbi->dwAlign == CCS_BOTTOM) { re.bottom = re.top + 4; if (PtInRect(&re, pt)) return (HTTOP); } else if (lpbi->dwAlign == CCS_TOP) { re.top = re.bottom - 4; if (PtInRect(&re, pt)) return (HTBOTTOM); } } return (HTCLIENT); case WM_NCCALCSIZE: { if (wParam == TRUE) { NCCALCSIZE_PARAMS *ncp = (NCCALCSIZE_PARAMS *) lParam; if (lpbi->dwAlign == CCS_LEFT) { ncp->rgrc[0].top += 4; ncp->rgrc[0].right -= 4; } else if (lpbi->dwAlign == CCS_RIGHT) { ncp->rgrc[0].top += 4; ncp->rgrc[0].left += 4; } else if (lpbi->dwAlign == CCS_BOTTOM) { ncp->rgrc[0].top += 4; } else if (lpbi->dwAlign == CCS_TOP) { ncp->rgrc[0].bottom -= 4; } else { ncp->rgrc[0].top += 4; ncp->rgrc[0].right -= 4; ncp->rgrc[0].left += 4; ncp->rgrc[0].bottom -= 4; } } } break; case WM_ERASEBKGND: return (TRUE); case WM_NCPAINT: { HDC hdc = GetWindowDC(hwnd); RECT rcWindow, rcClient; if (hdc == NULL) break; GetClientRect(hwnd, &rcClient); GetWindowRect(hwnd, &rcWindow); MapWindowPoints(NULL, hwnd, (LPPOINT)&rcWindow, 2); OffsetRect(&rcClient, -rcWindow.left, -rcWindow.top); OffsetRect(&rcWindow, -rcWindow.left, -rcWindow.top); ExcludeClipRect(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); FillRect(hdc, &rcWindow, (HBRUSH)GetSysColorBrush(COLOR_BTNFACE)); ReleaseDC(hwnd, hdc); } return (TRUE); case BCM_SETCLIENTWND: { REBARBANDINFO rbBand; ZeroMemory(&rbBand, sizeof(REBARBANDINFO)); rbBand.cbSize = sizeof(REBARBANDINFO); rbBand.fMask = RBBIM_CHILDSIZE | RBBIM_CHILD; rbBand.cyIntegral = 1; rbBand.cyMaxChild = -1; rbBand.hwndChild = (HWND)lParam; return (SendMessage(lpbi->hwndRebar, RB_SETBANDINFO, 0, (LPARAM)&rbBand)); } case BCM_GETCLIENTWND: { REBARBANDINFO rbBand; ZeroMemory(&rbBand, sizeof(REBARBANDINFO)); rbBand.cbSize = sizeof(REBARBANDINFO); rbBand.fMask = RBBIM_CHILD; SendMessage(lpbi->hwndRebar, RB_GETBANDINFO, 0, (LPARAM)&rbBand); return (LRESULT)((IsWindow(rbBand.hwndChild) ? rbBand.hwndChild : NULL)); } case BCM_SETIMAGELIST: { REBARINFO rbi; HIMAGELIST hilOld = BandCtrl_GetImageList(hwnd); rbi.cbSize = sizeof(REBARINFO); rbi.fMask = RBIM_IMAGELIST; rbi.himl = (HIMAGELIST)lParam; if (!SendMessage(lpbi->hwndRebar, RB_SETBARINFO, 0, (LPARAM) &rbi)) return ((LRESULT)NULL); return ((LRESULT)hilOld); } case BCM_GETIMAGELIST: { REBARINFO rbi; rbi.cbSize = sizeof(REBARINFO); rbi.fMask = RBIM_IMAGELIST; rbi.himl = 0; if (!SendMessage(lpbi->hwndRebar, RB_GETBARINFO, 0, (LPARAM) &rbi)) return ((LRESULT)NULL); return ((LRESULT)rbi.himl); } case BCM_SETTITLEIMAGE: { REBARBANDINFO rbBand; ZeroMemory(&rbBand, sizeof(REBARBANDINFO)); rbBand.cbSize = sizeof(REBARBANDINFO); rbBand.fMask = RBBIM_IMAGE; rbBand.iImage = wParam; return (SendMessage(lpbi->hwndRebar, RB_SETBANDINFO, 0, (LPARAM)&rbBand)); } case BCM_GETTITLEIMAGE: { REBARBANDINFO rbBand; ZeroMemory(&rbBand, sizeof(REBARBANDINFO)); rbBand.cbSize = sizeof(REBARBANDINFO); rbBand.fMask = RBBIM_IMAGE; rbBand.iImage = -1; SendMessage(lpbi->hwndRebar, RB_GETBANDINFO, 0, (LPARAM)&rbBand); return (rbBand.iImage); } case BCM_GETALIGNMENT: return ((LRESULT)lpbi->dwAlign); case BCM_SETALIGNMENT: { NMHDR nmhdr; DWORD dwStyle; if (lpbi->dwAlign == wParam) return (wParam); lpbi->dwAlign = wParam; dwStyle = GetWindowLong(lpbi->hwndRebar, GWL_STYLE); dwStyle &= ~(CCS_BOTTOM | CCS_TOP | CCS_LEFT | CCS_RIGHT); dwStyle |= lpbi->dwAlign; SetWindowLong(lpbi->hwndRebar, GWL_STYLE, dwStyle); SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); nmhdr.code = RBN_HEIGHTCHANGE; nmhdr.hwndFrom = hwnd; nmhdr.idFrom = GetDlgCtrlID(hwnd); SendMessage(GetParent(hwnd), WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr); return (lpbi->dwAlign); } case BCM_SETDATA: { LPARAM lParamOld = lpbi->lParam; lpbi->lParam = lParam; return (lParamOld); } case BCM_GETDATA: return (lpbi->lParam); case BCM_SETALLOWABLEALIGNS: { DWORD dwOldAllowableAligns = lpbi->dwAllowableAligns; lpbi->dwAllowableAligns = lParam; return (dwOldAllowableAligns); } case BCM_GETALLOWABLEALIGNS: return (lpbi->dwAllowableAligns); } return (DefWindowProc(hwnd, uMessage, wParam, lParam)); }
static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { MButtonCtrl *bct = (MButtonCtrl *) GetWindowLong(hwndDlg, 0); switch (msg) { case WM_NCCREATE: { SetWindowLong(hwndDlg, GWL_STYLE, GetWindowLong(hwndDlg, GWL_STYLE) | BS_OWNERDRAW); bct = malloc(sizeof(MButtonCtrl)); if (bct == NULL) return FALSE; bct->hwnd = hwndDlg; bct->stateId = PBS_NORMAL; bct->focus = 0; bct->hFont = GetStockObject(DEFAULT_GUI_FONT); bct->arrow = NULL; bct->defbutton = 0; bct->hIcon = bct->hIconPrivate = 0; bct->iIcon = 0; bct->hIml = 0; bct->hBitmap = NULL; bct->pushBtn = 0; bct->pbState = 0; bct->hThemeButton = NULL; bct->hThemeToolbar = NULL; bct->cHot = 0; bct->flatBtn = 0; bct->bThemed = FALSE; bct->bSkinned = bct->bSendOnDown = 0; bct->buttonItem = NULL; LoadTheme(bct); SetWindowLong(hwndDlg, 0, (LONG) bct); if (((CREATESTRUCTA *) lParam)->lpszName) SetWindowText(hwndDlg, ((CREATESTRUCT *) lParam)->lpszName); return TRUE; } case WM_DESTROY: { if (bct) { if (hwndToolTips) { TOOLINFO ti; ZeroMemory(&ti, sizeof(ti)); ti.cbSize = sizeof(ti); ti.uFlags = TTF_IDISHWND; ti.hwnd = bct->hwnd; ti.uId = (UINT) bct->hwnd; if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM) &ti)) { SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM) &ti); } if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM) &ti) == 0) { DestroyWindow(hwndToolTips); hwndToolTips = NULL; } } if (bct->hIconPrivate) DestroyIcon(bct->hIconPrivate); DestroyTheme(bct); free(bct); } SetWindowLong(hwndDlg, 0, (LONG) NULL); break; // DONT! fall thru } case WM_SETTEXT: { bct->cHot = 0; if ((char*) lParam) { char *tmp = (char *) lParam; while (*tmp) { if (*tmp == '&' && *(tmp + 1)) { bct->cHot = tolower(*(tmp + 1)); break; } tmp++; } InvalidateRect(bct->hwnd, NULL, TRUE); lstrcpyn(bct->szText, (TCHAR *)lParam, 127); bct->szText[127] = 0; } break; } case WM_SYSKEYUP: if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == tolower((int) wParam)) { if (bct->pushBtn) { if (bct->pbState) bct->pbState = 0; else bct->pbState = 1; InvalidateRect(bct->hwnd, NULL, TRUE); } if(!bct->bSendOnDown) SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg); return 0; } break; case WM_THEMECHANGED: { // themed changed, reload theme object if (bct->bThemed) LoadTheme(bct); InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it break; } case WM_SETFONT: // remember the font so we can use it later { bct->hFont = (HFONT) wParam; // maybe we should redraw? break; } case WM_NCPAINT: case WM_PAINT: { PAINTSTRUCT ps; HDC hdcPaint; hdcPaint = BeginPaint(hwndDlg, &ps); if (hdcPaint) { PaintWorker(bct, hdcPaint); EndPaint(hwndDlg, &ps); } break; } case BM_GETIMAGE: if(wParam == IMAGE_ICON) return (LRESULT)(bct->hIconPrivate ? bct->hIconPrivate : bct->hIcon); break; case BM_SETIMAGE: if(!lParam) break; bct->hIml = 0; bct->iIcon = 0; if (wParam == IMAGE_ICON) { ICONINFO ii = {0}; BITMAP bm = {0}; if (bct->hIconPrivate) { DestroyIcon(bct->hIconPrivate); bct->hIconPrivate = 0; } GetIconInfo((HICON) lParam, &ii); GetObject(ii.hbmColor, sizeof(bm), &bm); if (bm.bmWidth > g_cxsmIcon || bm.bmHeight > g_cysmIcon) { HIMAGELIST hImageList; hImageList = ImageList_Create(g_cxsmIcon, g_cysmIcon, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, 1, 0); ImageList_AddIcon(hImageList, (HICON) lParam); bct->hIconPrivate = ImageList_GetIcon(hImageList, 0, ILD_NORMAL); ImageList_RemoveAll(hImageList); ImageList_Destroy(hImageList); bct->hIcon = 0; } else { bct->hIcon = (HICON) lParam; bct->hIconPrivate = 0; } DeleteObject(ii.hbmMask); DeleteObject(ii.hbmColor); bct->hBitmap = NULL; InvalidateRect(bct->hwnd, NULL, TRUE); } else if (wParam == IMAGE_BITMAP) { bct->hBitmap = (HBITMAP) lParam; if (bct->hIconPrivate) DestroyIcon(bct->hIconPrivate); bct->hIcon = bct->hIconPrivate = NULL; InvalidateRect(bct->hwnd, NULL, TRUE); } break; case BM_SETPRIVATEICON: bct->hIml = 0; bct->iIcon = 0; { if (bct->hIconPrivate) DestroyIcon(bct->hIconPrivate); bct->hIconPrivate = DuplicateIcon(g_hInst, (HICON) lParam); bct->hIcon = 0; break; } case BM_SETIMLICON: { if (bct->hIconPrivate) DestroyIcon(bct->hIconPrivate); bct->hIml = (HIMAGELIST) wParam; bct->iIcon = (int) lParam; bct->hIcon = bct->hIconPrivate = 0; InvalidateRect(bct->hwnd, NULL, TRUE); break; } case BM_SETSKINNED: bct->bSkinned = (DWORD)lParam; bct->bThemed = bct->bSkinned ? FALSE : bct->bThemed; InvalidateRect(bct->hwnd, NULL, TRUE); break; case BM_SETBTNITEM: bct->buttonItem = (ButtonItem *)lParam; break; case BM_SETASMENUACTION: bct->bSendOnDown = wParam ? TRUE : FALSE; return 0; case BM_SETCHECK: if (!bct->pushBtn) break; if (wParam == BST_CHECKED) { bct->pbState = 1; bct->stateId = PBS_PRESSED; } else if (wParam == BST_UNCHECKED) { bct->pbState = 0; bct->stateId = PBS_NORMAL; } InvalidateRect(bct->hwnd, NULL, TRUE); break; case BM_GETCHECK: if (bct->pushBtn) { return bct->pbState ? BST_CHECKED : BST_UNCHECKED; } return 0; case BUTTONSETARROW: // turn arrow on/off if (wParam) { if (!bct->arrow) bct->arrow = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_MINIMIZE), IMAGE_ICON, g_cxsmIcon, g_cysmIcon, 0); } else { if (bct->arrow) { DestroyIcon(bct->arrow); bct->arrow = NULL; } } InvalidateRect(bct->hwnd, NULL, TRUE); break; case BUTTONSETDEFAULT: bct->defbutton = wParam ? 1 : 0; InvalidateRect(bct->hwnd, NULL, TRUE); break; case BUTTONSETASPUSHBTN: bct->pushBtn = 1; InvalidateRect(bct->hwnd, NULL, TRUE); break; case BUTTONSETASFLATBTN: bct->flatBtn = lParam == 0 ? 1 : 0; InvalidateRect(bct->hwnd, NULL, TRUE); break; case BUTTONSETASFLATBTN + 10: bct->bThemed = lParam ? TRUE : FALSE; bct->bSkinned = bct->bThemed ? 0 : bct->bSkinned; break; case BUTTONADDTOOLTIP: { TOOLINFO ti; if (!(char*) wParam) break; if (!hwndToolTips) { hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL); SetWindowPos(hwndToolTips, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); } ZeroMemory(&ti, sizeof(ti)); ti.cbSize = sizeof(ti); ti.uFlags = TTF_IDISHWND; ti.hwnd = bct->hwnd; ti.uId = (UINT) bct->hwnd; if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM) &ti)) { SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM) &ti); } ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; ti.uId = (UINT) bct->hwnd; ti.lpszText = (TCHAR *) wParam; SendMessage(hwndToolTips, TTM_ADDTOOL, 0, (LPARAM) &ti); break; } case WM_SETFOCUS: // set keybord focus and redraw bct->focus = 1; InvalidateRect(bct->hwnd, NULL, TRUE); break; case WM_KILLFOCUS: // kill focus and redraw bct->focus = 0; InvalidateRect(bct->hwnd, NULL, TRUE); break; case WM_WINDOWPOSCHANGED: InvalidateRect(bct->hwnd, NULL, TRUE); break; case WM_ENABLE: // windows tells us to enable/disable { bct->stateId = wParam ? PBS_NORMAL : PBS_DISABLED; InvalidateRect(bct->hwnd, NULL, TRUE); break; } case WM_MOUSELEAVE: // faked by the WM_TIMER { if (bct->stateId != PBS_DISABLED) { // don't change states if disabled bct->stateId = PBS_NORMAL; InvalidateRect(bct->hwnd, NULL, TRUE); } break; } case WM_LBUTTONDOWN: { if (bct->stateId != PBS_DISABLED && bct->stateId != PBS_PRESSED) { bct->stateId = PBS_PRESSED; InvalidateRect(bct->hwnd, NULL, TRUE); if(bct->bSendOnDown) { SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg); bct->stateId = PBS_NORMAL; InvalidateRect(bct->hwnd, NULL, TRUE); } } break; } case WM_LBUTTONUP: { if (bct->pushBtn) { if (bct->pbState) bct->pbState = 0; else bct->pbState = 1; } if (bct->stateId != PBS_DISABLED) { // don't change states if disabled if (msg == WM_LBUTTONUP) bct->stateId = PBS_HOT; else bct->stateId = PBS_NORMAL; InvalidateRect(bct->hwnd, NULL, TRUE); } if(!bct->bSendOnDown) SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg); break; } case WM_MOUSEMOVE: if (bct->stateId == PBS_NORMAL) { bct->stateId = PBS_HOT; InvalidateRect(bct->hwnd, NULL, TRUE); } // Call timer, used to start cheesy TrackMouseEvent faker SetTimer(hwndDlg, BUTTON_POLLID, BUTTON_POLLDELAY, NULL); break; case WM_NCHITTEST: { LRESULT lr = SendMessage(GetParent(hwndDlg), WM_NCHITTEST, wParam, lParam); if(lr == HTLEFT || lr == HTRIGHT || lr == HTBOTTOM || lr == HTTOP || lr == HTTOPLEFT || lr == HTTOPRIGHT || lr == HTBOTTOMLEFT || lr == HTBOTTOMRIGHT) return HTTRANSPARENT; break; } case WM_TIMER: // use a timer to check if they have did a mouseout { if (wParam == BUTTON_POLLID) { RECT rc; POINT pt; GetWindowRect(hwndDlg, &rc); GetCursorPos(&pt); if (!PtInRect(&rc, pt)) { // mouse must be gone, trigger mouse leave PostMessage(hwndDlg, WM_MOUSELEAVE, 0, 0L); KillTimer(hwndDlg, BUTTON_POLLID); } } break; } case WM_ERASEBKGND: return 1; } return DefWindowProc(hwndDlg, msg, wParam, lParam); }
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { PAERO_SUBCLASS_WND_DATA pWndData = (PAERO_SUBCLASS_WND_DATA)GetProp(hWnd, WINDOW_DATA_STRING); ASSERT(pWndData); ASSERT(pWndData->m_pDwmApiImpl); WNDPROC pOldProc = pWndData->m_oldWndProc; ASSERT(pOldProc); BOOL bCompositionEnabled = pWndData->m_pDwmApiImpl->IsDwmCompositionEnabled(); /// /// if aero glass is turned off and if we are not in destruction code, /// just call the original wnd proc we had prior to subclassing: /// if(WM_COMMAND!=uMsg && WM_DWMCOMPOSITIONCHANGED!=uMsg && WM_DESTROY!=uMsg && WM_NCDESTROY!=uMsg && !bCompositionEnabled) return CallWindowProc(pOldProc, hWnd, uMsg, wParam, lParam); if (uMsg == pWndData->m_uiRedrawMsg) { HWND hControl = (HWND)lParam; ASSERT(hControl); ASSERT(::IsWindow(hControl)); PAERO_SUBCLASS_WND_DATA pCtrlData = (PAERO_SUBCLASS_WND_DATA)GetProp(hControl, WINDOW_DATA_STRING); if(pCtrlData && pCtrlData->m_dwFlags & WD_IN_PAINT_CONTROL) { HDC hdc = GetDC(hControl); if(hdc) { RECT rc; VERIFY(GetWindowRect(hControl, &rc)); VERIFY(MapWindowPoints(NULL, hControl, (LPPOINT) &rc, 2)); PaintControl(hControl, hdc, &rc, (pCtrlData->m_dwFlags & WD_DRAW_BORDER)!=0); VERIFY(1==ReleaseDC(hControl, hdc)); } pCtrlData->m_dwFlags &= ~WD_IN_PAINT_CONTROL; return 0; } } switch(uMsg) { case WM_CTLCOLORSTATIC: { HWND hControl = (HWND)lParam; ASSERT(hControl); ASSERT(IsWindow(hControl)); PAERO_SUBCLASS_WND_DATA pCtrlData = (PAERO_SUBCLASS_WND_DATA)GetProp(hControl, WINDOW_DATA_STRING); if(pCtrlData) { if(pCtrlData->m_dwFlags&WD_RETURN_BLACK_BRUSH) return (LRESULT)GetStockObject(BLACK_BRUSH); else if(pCtrlData->m_dwFlags&WD_RETURN_WHITE_BRUSH) return (LRESULT)GetStockObject(WHITE_BRUSH); else { pCtrlData->m_dwFlags|=WD_IN_PAINT_CONTROL; PostMessage((HWND)lParam, pWndData->m_uiRedrawMsg, 0, NULL); } } } break; case WM_CTLCOLOREDIT: { PAERO_SUBCLASS_WND_DATA pCtrlData = (PAERO_SUBCLASS_WND_DATA)GetProp((HWND)lParam, WINDOW_DATA_STRING); if(pCtrlData) pCtrlData->m_dwFlags|=WD_IN_PAINT_CONTROL; PostMessage((HWND)lParam, pWndData->m_uiRedrawMsg, 0, NULL); } break; case WM_PAINT: { if(!IsIconic(hWnd) && !(pWndData->m_dwFlags&WD_NO_FRAME_EXTEND)) { PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); /// /// we have to paint the *entire* client area in black, not only the /// paint area inside ps, because otherwise we get ugly areas of white /// if we partially move the window out of the desktop and back in again: /// /// MARGINS marGlassInset = {-1, -1, -1, -1}; // -1 means the whole window if(hdc && pWndData->m_pDwmApiImpl->IsDwmCompositionEnabled() && SUCCEEDED(pWndData->m_pDwmApiImpl->DwmExtendFrameIntoClientArea(hWnd, &marGlassInset))) { RECT rcClient; VERIFY(GetClientRect(hWnd, &rcClient)); VERIFY(PatBlt(hdc, 0, 0, RECTWIDTH(rcClient), RECTHEIGHT(rcClient), BLACKNESS)); } EndPaint(hWnd, &ps); return 1; } } break; case WM_COMMAND: { if(bCompositionEnabled) { if(LBN_SELCHANGE==HIWORD(wParam)) { InvalidateRgn((HWND)lParam, NULL, TRUE); VERIFY(UpdateWindow((HWND)lParam)); } } if(ACN_STOP==HIWORD(wParam)) { /// /// if it is an animation control that has just stopped playing, /// reset the WD_PLAY flag so it repaints itself properly again if /// e.g. Aero is turned off an on again: /// PAERO_SUBCLASS_WND_DATA pCtrlData = (PAERO_SUBCLASS_WND_DATA)GetProp((HWND)lParam, WINDOW_DATA_STRING); if(pCtrlData) { pCtrlData->m_dwFlags&=~WD_PLAY; } } if(ACN_START==HIWORD(wParam)) { PAERO_SUBCLASS_WND_DATA pCtrlData = (PAERO_SUBCLASS_WND_DATA)GetProp((HWND)lParam, WINDOW_DATA_STRING); if(pCtrlData) { pCtrlData->m_dwFlags|=WD_PLAY; } } } break; case WM_NOTIFY: { LPNMHDR lpnmh = (LPNMHDR)lParam; if(lpnmh) { ASSERT(lpnmh->hwndFrom); ASSERT(IsWindow(lpnmh->hwndFrom)); switch(lpnmh->code) { case LVN_ITEMCHANGED: { /// /// if we select and deselect list view items, /// its header control sometimes vanishes so /// we have to force a redraw: /// HWND hHeader = ListView_GetHeader(lpnmh->hwndFrom); if(hHeader) { InvalidateRgn(hHeader, NULL, TRUE); VERIFY(UpdateWindow(hHeader)); } } break; default: break; } } } break; case WM_DESTROY: ASSERT(pWndData->m_pUxTheme); ASSERT(pWndData->m_pDwmApiImpl); VERIFY(SUCCEEDED(pWndData->m_pUxTheme->BufferedPaintUnInit())); delete pWndData->m_pUxTheme; delete pWndData->m_pDwmApiImpl; if(WndProc==(WNDPROC)GetWindowLongPtr(hWnd, GWLP_WNDPROC)) { VERIFY(WndProc==(WNDPROC) SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) pWndData->m_oldWndProc)); VERIFY(pWndData==RemoveProp(hWnd, WINDOW_DATA_STRING)); VERIFY(!LocalFree(pWndData)); } break; case WM_NCDESTROY: if(WndProc==(WNDPROC)GetWindowLongPtr(hWnd, GWLP_WNDPROC)) { VERIFY(WndProc==(WNDPROC) SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) pWndData->m_oldWndProc)); VERIFY(pWndData==RemoveProp(hWnd, WINDOW_DATA_STRING)); VERIFY(!LocalFree(pWndData)); } break; } return CallWindowProc(pOldProc, hWnd, uMsg, wParam, lParam); }
static void init_datasette_dialog(HWND hwnd) { HWND snd_hwnd; int res_value; int res_value_loop; int active_value; int xpos_max; int group_max; RECT rect; /* translate all dialog items */ uilib_localize_dialog(hwnd, datasette_dialog); /* adjust the size of the elements in the datasette_sub_group */ uilib_adjust_group_width(hwnd, datasette_sub_group); /* adjust the size of the 'reset with cpu' element */ uilib_adjust_element_width(hwnd, IDC_DATASETTE_RESET_WITH_CPU); /* adjust the size of the motor group element */ uilib_adjust_element_width(hwnd, IDC_DATASETTE_MOTOR_GROUP); /* get the max x of the datasette_sub_group */ uilib_get_group_max_x(hwnd, datasette_sub_group, &xpos_max); /* get the max x of the motor group element */ uilib_get_element_max_x(hwnd, IDC_DATASETTE_MOTOR_GROUP, &group_max); /* calculate the max x of the motor group element and the datasette_sub_group elements */ if (group_max < xpos_max + 10) { group_max = xpos_max + 10; } /* set the width of the motor group element to 'surround' the datasette_sub_group elements */ uilib_set_element_width(hwnd, IDC_DATASETTE_MOTOR_GROUP, group_max); /* get the max x of the datasette_main_group elements */ uilib_get_group_max_x(hwnd, datasette_main_group, &xpos_max); /* set the width of the dialog to 'surround' all the elements */ GetWindowRect(hwnd, &rect); MoveWindow(hwnd, rect.left, rect.top, xpos_max + 10, rect.bottom - rect.top, TRUE); /* recenter the buttons in the newly resized dialog window */ uilib_center_buttons(hwnd, move_buttons_group, 0); resources_get_int("DatasetteResetWithCPU", &res_value); CheckDlgButton(hwnd, IDC_DATASETTE_RESET_WITH_CPU, res_value ? BST_CHECKED : BST_UNCHECKED); snd_hwnd = GetDlgItem(hwnd, IDC_DATASETTE_ZERO_GAP_DELAY); for (res_value_loop = 0; res_value_loop < 7; res_value_loop++) { TCHAR st[10]; _stprintf(st, TEXT("%d"), ui_datasette_zero_gap_delay[res_value_loop]); SendMessage(snd_hwnd, CB_ADDSTRING, 0, (LPARAM)st); } resources_get_int("DatasetteZeroGapDelay", &res_value); active_value = 4; /* default */ for (res_value_loop = 0; res_value_loop < 7; res_value_loop++) { if (ui_datasette_zero_gap_delay[res_value_loop] == res_value) { active_value = res_value_loop; } } SendMessage(snd_hwnd, CB_SETCURSEL, (WPARAM)active_value, 0); snd_hwnd = GetDlgItem(hwnd, IDC_DATASETTE_SPEED_TUNING); for (res_value_loop = 0; res_value_loop < 8; res_value_loop++) { TCHAR st[10]; _stprintf(st, TEXT("%d"), res_value_loop); SendMessage(snd_hwnd, CB_ADDSTRING, 0, (LPARAM)st); } resources_get_int("DatasetteSpeedTuning", &res_value); SendMessage(snd_hwnd, CB_SETCURSEL, (WPARAM)res_value, 0); }
LRESULT CALLBACK SpltWe_WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static int oldx; static int y; static int line_height; static int min_left; static int max_right; POINT pt; HDC hdc; RECT rect; HWND hp = GetParent(hwnd); switch (message) { case WM_CREATE: return 0 ; case WM_LBUTTONDOWN: SetCapture(hwnd); we_sizing = 1; line_height = win_height(hwnd); y = win_top(hwnd);; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetWindowRect(hp,&rect); min_left = rect.left + MIN_SPLT_SPACE; max_right = rect.right - MIN_SPLT_SPACE; //GetClientRect(hwnd,&splt_rect); //SCreenToClient(rect); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; ClientToScreen(hwnd,&pt); //convert the mouse coordinates relative to the top-left of //the window //ScreenToClient(hwnd_frame,&pt); if(pt.x < min_left) pt.x = min_left; if(pt.x > max_right) { pt.x = max_right; } hdc = GetDC(NULL); DrawXorBar(hdc, pt.x-SPLT_WIDTH/2, y, SPLT_WIDTH, line_height); ReleaseDC(NULL, hdc); oldx = pt.x; break; case WM_LBUTTONUP: ReleaseCapture(); pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetClientRect(hp,&rect); //GetClientRect(hwnd,&splt_rect); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; hdc = GetDC(NULL); DrawXorBar(hdc, oldx-SPLT_WIDTH/2, y, SPLT_WIDTH, line_height); ReleaseDC(NULL, hdc); we_sizing = 0; pt.x = oldx; ScreenToClient(hp,&pt); send_splitter_x(hp, pt.x); break; case WM_MOUSEMOVE: if(0==we_sizing) break; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); //GetClientRect(hwnd_frame,&rect); //GetClientRect(hwnd,&splt_rect); //SCreenToClient(rect); ClientToScreen(hwnd,&pt); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; //convert the mouse coordinates relative to the top-left of //the window //ScreenToClient(hwnd_frame,&pt); if(pt.x < min_left) pt.x = min_left; if(pt.x > max_right) { pt.x = max_right; } if(pt.x != oldx && wParam & MK_LBUTTON) { hdc = GetDC(NULL); DrawXorBar(hdc, oldx-SPLT_WIDTH/2, y, SPLT_WIDTH, line_height); DrawXorBar(hdc, pt.x-SPLT_WIDTH/2, y, SPLT_WIDTH, line_height); ReleaseDC(NULL, hdc); oldx = pt.x; } break; } return DefWindowProc (hwnd, message, wParam, lParam) ; }
INT_PTR CALLBACK PinCtrlDlgProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_CLOSE: { RECT rc; GetWindowRect(hWndDlg, &rc); axisx = rc.left; axisy = rc.top; hWndPinCtrl = NULL; EndDialog(hWndDlg, 0); return 0; } case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_PINCTRL_OK: if(HIWORD(wParam) != BN_CLICKED) return 0; if(msg.hComPort == INVALID_HANDLE_VALUE) { MessageBox(hWndDlg, "没有串口设备被打开!", COMMON_NAME, MB_ICONINFORMATION); return 0; } cconfig.dcb.fDtrControl = dtr[ComboBox_GetCurSel(hDtr)]; cconfig.dcb.fRtsControl = rts[ComboBox_GetCurSel(hRts)]; if(!SetCommConfig(msg.hComPort, &cconfig, sizeof(cconfig))) { utils.msgerr("设置DTR/RTS时错误!"); return 0; } EnableWindow(GetDlgItem(hWndDlg, IDC_PINCTRL_OK), FALSE); break; case IDC_CBO_PINCTRL_DTR: case IDC_CBO_PINCTRL_RTS: if(HIWORD(wParam) == CBN_SELENDOK) { EnableWindow(GetDlgItem(hWndDlg, IDC_PINCTRL_OK), TRUE); return 0; } break; } return 0; } case WM_INITDIALOG: { DWORD size = sizeof(cconfig); if(msg.hComPort == INVALID_HANDLE_VALUE) { utils.msgbox(MB_ICONEXCLAMATION, COMMON_NAME, "请先打开一个串口设备!"); EndDialog(hWndDlg, 0); return 0; } if(!GetCommConfig(msg.hComPort, &cconfig, &size)) { utils.msgerr("获取串口配置时错误"); EndDialog(hWndDlg, 0); return 0; } hDtr = GetDlgItem(hWndDlg, IDC_CBO_PINCTRL_DTR); hRts = GetDlgItem(hWndDlg, IDC_CBO_PINCTRL_RTS); for(;;) { int i; for(i = 0; i < 3; i++) { ComboBox_AddString(hDtr, sdtr[i]); ComboBox_AddString(hRts, srts[i]); } ComboBox_SetCurSel(hDtr, cconfig.dcb.fDtrControl); ComboBox_SetCurSel(hRts, cconfig.dcb.fRtsControl); break; } //... hWndPinCtrl = hWndDlg; SetWindowPos(hWndDlg, 0, axisx, axisy, 0, 0, SWP_NOSIZE | SWP_NOZORDER); return 0; } } UNREFERENCED_PARAMETER(lParam); return 0; }
bool CCEGLView::Create(LPCTSTR pTitle, int w, int h) { bool bRet = false; do { CC_BREAK_IF(m_hWnd); HINSTANCE hInstance = GetModuleHandle( NULL ); WNDCLASS wc; // Windows Class Structure // Redraw On Size, And Own DC For Window. wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = _WindowProc; // WndProc Handles Messages wc.cbClsExtra = 0; // No Extra Window Data wc.cbWndExtra = 0; // No Extra Window Data wc.hInstance = hInstance; // Set The Instance wc.hIcon = LoadIcon( NULL, IDI_WINLOGO ); // Load The Default Icon wc.hCursor = LoadCursor( NULL, IDC_ARROW ); // Load The Arrow Pointer wc.hbrBackground = NULL; // No Background Required For GL wc.lpszMenuName = NULL; // We Don't Want A Menu wc.lpszClassName = kWindowClassName; // Set The Class Name CC_BREAK_IF(! RegisterClass(&wc) && 1410 != GetLastError()); // center window position RECT rcDesktop; GetWindowRect(GetDesktopWindow(), &rcDesktop); // create window m_hWnd = CreateWindowEx( WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window kWindowClassName, // Class Name pTitle, // Window Title WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX, // Defined Window Style 0, 0, // Window Position 0, // Window Width 0, // Window Height NULL, // No Parent Window NULL, // No Menu hInstance, // Instance NULL ); CC_BREAK_IF(! m_hWnd); m_eInitOrientation = CCDirector::sharedDirector()->getDeviceOrientation(); m_bOrientationInitVertical = (CCDeviceOrientationPortrait == m_eInitOrientation || kCCDeviceOrientationPortraitUpsideDown == m_eInitOrientation) ? true : false; m_tSizeInPoints.cx = w; m_tSizeInPoints.cy = h; resize(w, h); // init egl m_pEGL = CCEGL::create(this); if (! m_pEGL) { DestroyWindow(m_hWnd); m_hWnd = NULL; break; } s_pMainWindow = this; bRet = true; } while (0); return bRet; }
static inline INT_PTR CALLBACK AboutFunc(HWND a_hDlg, UINT a_message, WPARAM a_wParam, LPARAM a_lParam) { switch (a_message) { case WM_INITDIALOG: SendMessage( a_hDlg , WM_SETICON , TRUE , (LPARAM)g_hIcon ); SendMessage( a_hDlg , WM_SETICON , FALSE , (LPARAM)g_hIcon ); SetWindowText( a_hDlg , g_pTitle ); SendMessage( GetDlgItem( a_hDlg , s_ids.m_nIcon ) , STM_SETICON, (WPARAM)g_hIcon , 0L); SetDlgItemText( a_hDlg , s_ids.m_nAppName , g_pAppName ); SetDlgItemText( a_hDlg , s_ids.m_nLink , g_pUrl ); SetDlgItemText( a_hDlg , s_ids.m_nEdit , g_pProgrammed ); { RECT rcTmp = {}; GetWindowRect( a_hDlg , &rcTmp ); RECT rcMain1 = rcTmp; GetClientRect( a_hDlg , &rcTmp ); SIZE szClientSize = { rcTmp.right , rcTmp.bottom }; const SIZE szMainB = { (rcMain1.right - rcMain1.left) - rcTmp.right, (rcMain1.bottom - rcMain1.top) - rcTmp.bottom }; //----------------------------------------- CWndSize wIcon( GetDlgItem( a_hDlg , s_ids.m_nIcon ) ); CWndSize wAppName( GetDlgItem( a_hDlg , s_ids.m_nAppName ) ); CWndSize wLink( GetDlgItem( a_hDlg , s_ids.m_nLink ) ); CWndSize wP2( GetDlgItem( a_hDlg , s_ids.m_nText0 ) ); CWndSize wProgrammed( GetDlgItem( a_hDlg , s_ids.m_nEdit ) ); //-------------------------------------------------- int nMaxHeight_Link = 0; int nMaxWidth_Link = 0; if( wLink.GetHWND() ) { nMaxHeight_Link = (int)::SendMessage( wLink.GetHWND() , LM_GETIDEALHEIGHT , 0 , 0 ); nMaxWidth_Link = 0; int nHeight1; int nHeight2; SIZE size = {}; do { nMaxWidth_Link++; nHeight1 = (int)::SendMessage( wLink.GetHWND() , LM_GETIDEALSIZE , (WPARAM)nMaxWidth_Link , (LPARAM)&size ); nHeight2 = (int)::SendMessage( wLink.GetHWND() , LM_GETIDEALSIZE , (WPARAM)nMaxWidth_Link + 2 , (LPARAM)&size ); } while ( nMaxHeight_Link != nHeight1 || nMaxHeight_Link != nHeight2 ); } if( nMaxWidth_Link < (szClientSize.cx - 8*2) ) { //nMaxWidth_Link = (szClientSize.cx - 8*2); } else szClientSize.cx = nMaxWidth_Link + 8*2; szClientSize.cy = 8 + wIcon.GetSize().cy + 2 + wAppName.GetSize().cy + 16 + nMaxHeight_Link + 16 + wP2.GetSize().cy + 2 + wProgrammed.GetSize().cy + 8; MoveWindow( a_hDlg , rcMain1.left , rcMain1.top , szClientSize.cx + szMainB.cx , szClientSize.cy + szMainB.cy , TRUE ); // int posY = 8; wIcon.SetC_X( szClientSize.cx , posY , wIcon.GetSize().cx , wIcon.GetSize().cy ); posY += (2 + wIcon.GetSize().cy); //SetWindowLong( wAppName.GetHWND() , GWL_STYLE , GetWindowLong( wAppName.GetHWND() , GWL_STYLE ) | SS_CENTER ); wAppName.SetC_X( szClientSize.cx , posY , szClientSize.cx , wAppName.GetSize().cy ); posY += (16 + wAppName.GetSize().cy); wLink.SetC_X( szClientSize.cx , posY , nMaxWidth_Link , nMaxHeight_Link ); posY += (16 + wLink.GetSize().cy); //SetWindowLong( wP2.GetHWND() , GWL_STYLE , GetWindowLong( wP2.GetHWND() , GWL_STYLE ) | SS_CENTER ); wP2.SetC_X( szClientSize.cx , posY , szClientSize.cx , wP2.GetSize().cy ); posY += (2 + wP2.GetSize().cy); wProgrammed.SetC_X( szClientSize.cx , posY , szClientSize.cx , wProgrammed.GetSize().cy ); posY += (2 + wProgrammed.GetSize().cy); } return (INT_PTR)TRUE; case WM_NOTIFY: { const LPNMHDR pNMHdr = (LPNMHDR)a_lParam; switch (pNMHdr->code) { //case NM_RETURN: case NM_CLICK: { const PNMLINK pNMLink = (PNMLINK)a_lParam; if( *pNMLink->item.szUrl ) ShellExecute( NULL , L"open" , pNMLink->item.szUrl , NULL , NULL , SW_SHOW ); } break; }; } case WM_COMMAND: if (LOWORD(a_wParam) == IDOK || LOWORD(a_wParam) == IDCANCEL) { EndDialog( a_hDlg , LOWORD(a_wParam) ); return (INT_PTR)TRUE; } break; } return (INT_PTR)FALSE; }
/*------------------------------------------------ initialize --------------------------------------------------*/ void OnInit(HWND hDlg) { PMOUSESTRUCT pitem; RECT rc; BOOL b; m_bInit = FALSE; if(GetMyRegLong(m_section, "ver031031", 0) == 0) { SetMyRegLong(m_section, "ver031031", 1); ImportOldMouseFunc(); // common/mousestruct.c } // common/mousestruct.c m_pMouseCommand = LoadMouseFunc(); // common/tclang.c SetDialogLanguage(hDlg, "Mouse", g_hfontDialog); GetWindowRect(GetDlgItem(hDlg, IDC_MOUSEOPT), &rc); m_widthOpt = rc.right - rc.left; CBAddString(hDlg, IDC_MOUSEBUTTON, (LPARAM)MyString(IDS_LEFTBUTTON, "LButton")); CBAddString(hDlg, IDC_MOUSEBUTTON, (LPARAM)MyString(IDS_RIGHTBUTTONM, "RButton")); CBAddString(hDlg, IDC_MOUSEBUTTON, (LPARAM)MyString(IDS_MIDDLEBUTTONM, "MButton")); CBAddString(hDlg, IDC_MOUSEBUTTON, (LPARAM)MyString(IDS_XBUTTON1, "XButton1")); CBAddString(hDlg, IDC_MOUSEBUTTON, (LPARAM)MyString(IDS_XBUTTON2, "XButton2")); #if TC_ENABLE_WHEEL CBAddString(hDlg, IDC_MOUSEBUTTON, (LPARAM)MyString(IDS_WHEELUP, "WheelUp")); CBAddString(hDlg, IDC_MOUSEBUTTON, (LPARAM)MyString(IDS_WHEELDOWN, "WheelDown")); #endif InitFunction(hDlg, IDC_MOUSEFUNC); pitem = m_pMouseCommand; while(pitem) { CBAddString(hDlg, IDC_NAMECLICK, (LPARAM)pitem->name); pitem = pitem->next; } m_nCurrent = -1; CBSetCurSel(hDlg, IDC_NAMECLICK, 0); OnName(hDlg); CheckDlgButton(hDlg, IDC_LMOUSEPASSTHRU, GetMyRegLong(m_section, "LeftMousePassThrough", (g_winver&WIN10RS1) != 0)); b = GetMyRegLong(NULL, "RightClickMenu", TRUE); b = GetMyRegLong(m_section, "RightClickMenu", b); CheckDlgButton(hDlg, IDC_RCLICKMENU, b); m_bInit = TRUE; }
void CBacnetVariable::OnNMClickListVariable(NMHDR *pNMHDR, LRESULT *pResult) { LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR); // TODO: Add your control notification handler code here long lRow,lCol; m_variable_list.Set_Edit(true); DWORD dwPos=GetMessagePos();//Get which line is click by user.Set the check box, when user enter Insert it will jump to program dialog CPoint point( LOWORD(dwPos), HIWORD(dwPos)); m_variable_list.ScreenToClient(&point); LVHITTESTINFO lvinfo; lvinfo.pt=point; lvinfo.flags=LVHT_ABOVE; int nItem=m_variable_list.SubItemHitTest(&lvinfo); lRow = lvinfo.iItem; lCol = lvinfo.iSubItem; if(lRow>m_variable_list.GetItemCount()) //如果点击区超过最大行号,则点击是无效的 return; if(lRow<0) return; CString temp1; m_row = lRow; m_col = lCol; memcpy_s(&m_temp_variable_data[lRow],sizeof(Str_variable_point),&m_Variable_data.at(lRow),sizeof(Str_variable_point)); CString New_CString; CString temp_task_info; if((lCol == VARIABLE_VALUE) &&(m_Variable_data.at(lRow).digital_analog == BAC_UNITS_DIGITAL ) && (m_Variable_data.at(lRow).auto_manual != BAC_AUTO)) { CString temp1; CStringArray temparray; if((m_Variable_data.at(lRow).range < 23) &&(m_Variable_data.at(lRow).range !=0)) temp1 = Digital_Units_Array[m_Variable_data.at(lRow).range]; else if((m_Variable_data.at(lRow).range >=23) && (m_Variable_data.at(lRow).range <= 30)) { if(receive_customer_unit) temp1 = temp_unit_no_index[m_Variable_data.at(lRow).range - 23]; else { m_variable_list.Set_Edit(false); return; } } else return; SplitCStringA(temparray,temp1,_T("/")); if(m_Variable_data.at(lRow).control == 0) { m_Variable_data.at(lRow).control = 1; m_variable_list.SetItemText(lRow,VARIABLE_VALUE,temparray.GetAt(1)); New_CString = temparray.GetAt(1); } else { m_Variable_data.at(lRow).control = 0; m_variable_list.SetItemText(lRow,VARIABLE_VALUE,temparray.GetAt(0)); New_CString = temparray.GetAt(0); } m_variable_list.Set_Edit(false); temp_task_info.Format(_T("Write Variable List Item%d .Changed to \"%s\" "),lRow + 1,New_CString); } else if((lCol == VARIABLE_VALUE) &&(m_Variable_data.at(lRow).digital_analog == BAC_UNITS_ANALOG ) && (m_Variable_data.at(lRow).auto_manual == BAC_MANUAL) && (m_Variable_data.at(lRow).range == 20)) { m_variable_list.Set_Edit(false); m_variable_time_picker.ShowWindow(SW_SHOW); CRect list_rect,win_rect; m_variable_list.GetWindowRect(list_rect); GetWindowRect(win_rect); CRect myrect; m_variable_list.GetSubItemRect(lRow,lCol,LVIR_BOUNDS,myrect); myrect.left = myrect.left + list_rect.left - win_rect.left +2 ; myrect.right = myrect.right + list_rect.left - win_rect.left + 2; //myrect.top = myrect.top + 11; //myrect.bottom = myrect.bottom + 13; myrect.top = myrect.top + 24; myrect.bottom = myrect.bottom + 26; m_variable_time_picker.BringWindowToTop(); m_variable_time_picker.MoveWindow(myrect); CString Temp_CString = m_variable_list.GetItemText(lRow,lCol); CStringArray TEMPCS; int temp_hour,temp_minute; SplitCStringA(TEMPCS, Temp_CString, _T(":")); if((int)TEMPCS.GetSize() <2) { temp_hour = 0; temp_minute = 0; CTime TimeTemp(2014,1,1,temp_hour,temp_minute,0); m_variable_time_picker.SetFormat(_T("HH:mm")); m_variable_time_picker.SetTime(&TimeTemp); m_variable_time_picker.SetFocus(); } else { temp_hour = _wtoi(TEMPCS.GetAt(0)); temp_minute = _wtoi(TEMPCS.GetAt(1)); CTime TimeTemp(2014,1,1,temp_hour,temp_minute,0); m_variable_time_picker.SetFormat(_T("HH:mm")); m_variable_time_picker.SetTime(&TimeTemp); m_variable_time_picker.SetFocus(); } m_variable_list.SetItemText(lRow,lCol,_T("")); m_variable_time_picker.Invalidate(); SetTimer(2,100,NULL); } else if(lCol == VARIABLE_VALUE) { if(m_Variable_data.at(lRow).auto_manual == BAC_AUTO) { m_variable_list.Set_Edit(false); return; } } else if(lCol == VARIABLE_AUTO_MANUAL) { if(m_Variable_data.at(lRow).auto_manual == 0) { m_Variable_data.at(lRow).auto_manual = 1; m_variable_list.SetItemText(lRow,VARIABLE_AUTO_MANUAL,_T("Manual")); //m_variable_list.SetCellEnabled(lRow,VARIABLE_VALUE,TRUE); New_CString = _T("Manual"); } else { m_Variable_data.at(lRow).auto_manual = 0; m_variable_list.SetItemText(lRow,VARIABLE_AUTO_MANUAL,_T("Auto")); //m_variable_list.SetCellEnabled(lRow,VARIABLE_VALUE,FALSE); New_CString = _T("Auto"); } temp_task_info.Format(_T("Write Variable List Item%d .Changed to \"%s\" "),lRow + 1,New_CString); } else if(lCol == VARIABLE_UNITE) { BacnetRange dlg; //点击产品的时候 需要读customer units,老的产品firmware 说不定没有 这些,所以不强迫要读到; if(!read_customer_unit) { int temp_invoke_id = -1; int send_status = true; int resend_count = 0; for (int z=0;z<3;z++) { do { resend_count ++; if(resend_count>5) { send_status = false; break; } temp_invoke_id = GetPrivateData( g_bac_instance, READUNIT_T3000, 0, BAC_CUSTOMER_UNITS_COUNT - 1, sizeof(Str_Units_element)); Sleep(SEND_COMMAND_DELAY_TIME); } while (g_invoke_id<0); if(send_status) { for (int z=0;z<1000;z++) { Sleep(1); if(tsm_invoke_id_free(temp_invoke_id)) { read_customer_unit = true; break; } else continue; } } if(read_customer_unit) break; } } //CString temp_cs = m_variable_list.GetItemText(lRow,lCol); //if(temp_cs.CompareNoCase(Units_Type[UNITS_TYPE_ANALOG])==0) //{ if(m_Variable_data.at(lRow).digital_analog == BAC_UNITS_ANALOG) { bac_ranges_type = VARIABLE_RANGE_ANALOG_TYPE; if(m_Variable_data.at(lRow).range > (sizeof(Variable_Analog_Units_Array) / sizeof(Variable_Analog_Units_Array[0]))) { m_Variable_data.at(lRow).range = 0; bac_range_number_choose = 0; } } else { bac_ranges_type = VARIABLE_RANGE_DIGITAL_TYPE; if(m_Variable_data.at(lRow).range > 30) { m_Variable_data.at(lRow).range = 0; bac_range_number_choose = 0; } } initial_dialog = 1; bac_range_number_choose = m_Variable_data.at(lRow).range; //bac_ranges_type = VARIABLE_RANGE_ANALOG_TYPE; dlg.DoModal(); if(range_cancel) { PostMessage(WM_REFRESH_BAC_VARIABLE_LIST,lRow,REFRESH_ON_ITEM);//这里调用 刷新线程重新刷新会方便一点; return ; } if(bac_range_number_choose == 0) //如果选择的是 unused 就认为是analog 的unused;这样 能显示对应的value; { m_Variable_data.at(lRow).digital_analog = BAC_UNITS_ANALOG; bac_ranges_type = VARIABLE_RANGE_ANALOG_TYPE; } if(bac_ranges_type == VARIABLE_RANGE_ANALOG_TYPE) { m_Variable_data.at(lRow).digital_analog = BAC_UNITS_ANALOG; m_Variable_data.at(lRow).range = bac_range_number_choose; m_variable_list.SetItemText(lRow,lCol,Variable_Analog_Units_Array[bac_range_number_choose]); if(m_Variable_data.at(lRow).range == 20) //如果是时间; { char temp_char[50]; int time_seconds = m_Variable_data.at(lRow).value / 1000; intervaltotext(temp_char,time_seconds,0,0); CString temp_11; MultiByteToWideChar( CP_ACP, 0, temp_char, strlen(temp_char) + 1, temp_11.GetBuffer(MAX_PATH), MAX_PATH ); temp_11.ReleaseBuffer(); m_variable_list.SetItemText(lRow,VARIABLE_VALUE,temp_11); } else { CString cstemp_value; float temp_float_value; temp_float_value = ((float)m_Variable_data.at(lRow).value) / 1000; cstemp_value.Format(_T("%.3f"),temp_float_value); m_variable_list.SetItemText(lRow,VARIABLE_VALUE,cstemp_value); /* cstemp_value.Format(_T("%d"),m_Variable_data.at(Changed_Item).value); m_variable_list.SetItemText(Changed_Item,VARIABLE_VALUE,cstemp_value);*/ } } else if((bac_ranges_type == VARIABLE_RANGE_DIGITAL_TYPE) || (bac_ranges_type == INPUT_RANGE_DIGITAL_TYPE) || (bac_ranges_type == OUTPUT_RANGE_DIGITAL_TYPE)) { m_Variable_data.at(lRow).digital_analog = BAC_UNITS_DIGITAL; m_Variable_data.at(lRow).range = bac_range_number_choose; CStringArray temparray; if((bac_range_number_choose >= 23) && (bac_range_number_choose <= 30)) { //temp1.Format(_T("%s"), temp_unit_no_index[bac_range_number_choose - 23]); temp1 = temp_unit_no_index[bac_range_number_choose - 23]; } else temp1 = Digital_Units_Array[bac_range_number_choose];//22 is the sizeof the array SplitCStringA(temparray,temp1,_T("/")); if(m_Variable_data.at(lRow).control == 1) { if((temparray.GetSize()==2)&&(!temparray.GetAt(1).IsEmpty())) { m_variable_list.SetItemText(lRow,VARIABLE_VALUE,temparray.GetAt(1)); } } else { if((temparray.GetSize()==2)&&(!temparray.GetAt(0).IsEmpty())) { m_variable_list.SetItemText(lRow,VARIABLE_VALUE,temparray.GetAt(0)); } } m_variable_list.SetItemText(lRow,VARIABLE_UNITE,temp1); } } else { //m_variable_list.Set_Edit(false); return; } int cmp_ret = memcmp(&m_temp_variable_data[lRow],&m_Variable_data.at(lRow),sizeof(Str_variable_point)); if(cmp_ret!=0) { m_variable_list.SetItemBkColor(lRow,lCol,LIST_ITEM_CHANGED_BKCOLOR); Post_Write_Message(g_bac_instance,WRITEVARIABLE_T3000,lRow,lRow,sizeof(Str_variable_point),m_variable_dlg_hwnd,temp_task_info,lRow,lCol); } // GetDlgItem(IDC_BUTTON_VARIABLE_APPLY)->SetFocus(); *pResult = 0; }
static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static HBITMAP hbmp = NULL; HDC hdc; switch (uMsg) { case WM_INITDIALOG: { HWND hwnd; RECT r, rdlg, chrome, rtab, rcancel, rstart; int xoffset = 0, yoffset = 0; // Fetch the positions (in screen coordinates) of all the windows we need to tweak ZeroMemory(&chrome, sizeof(chrome)); AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE); GetWindowRect(hwndDlg, &rdlg); GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab); GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel); GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart); // Knock off the non-client area of the main dialogue to give just the client area rdlg.left -= chrome.left; rdlg.top -= chrome.top; rdlg.right -= chrome.right; rdlg.bottom -= chrome.bottom; // Translate them to client-relative coordinates wrt the main dialogue window rtab.right -= rtab.left - 1; rtab.bottom -= rtab.top - 1; rtab.left -= rdlg.left; rtab.top -= rdlg.top; rcancel.right -= rcancel.left - 1; rcancel.bottom -= rcancel.top - 1; rcancel.left -= rdlg.left; rcancel.top -= rdlg.top; rstart.right -= rstart.left - 1; rstart.bottom -= rstart.top - 1; rstart.left -= rdlg.left; rstart.top -= rdlg.top; // And then convert the main dialogue coordinates to just width/length rdlg.right -= rdlg.left - 1; rdlg.bottom -= rdlg.top - 1; rdlg.left = 0; rdlg.top = 0; // Load the bitmap into the bitmap control and fetch its dimensions hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP)); hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP); SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp); GetClientRect(hwnd, &r); xoffset = r.right; yoffset = r.bottom - rdlg.bottom; // Shift and resize the controls that require it rtab.left += xoffset; rtab.bottom += yoffset; rcancel.left += xoffset; rcancel.top += yoffset; rstart.left += xoffset; rstart.top += yoffset; rdlg.right += xoffset; rdlg.bottom += yoffset; // Move the controls to their new positions MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE); MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE); MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE); // Move the main dialogue to the centre of the screen hdc = GetDC(NULL); rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2; rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2; ReleaseDC(NULL, hdc); MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left, rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE); // Add tabs to the tab control { TCITEM tab; hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL); ZeroMemory(&tab, sizeof(tab)); tab.mask = TCIF_TEXT; tab.pszText = TEXT("Configuration"); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab); tab.mask = TCIF_TEXT; tab.pszText = TEXT("Game"); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_GAME, (LPARAM)&tab); tab.mask = TCIF_TEXT; tab.pszText = TEXT("Messages"); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab); // Work out the position and size of the area inside the tab control for the pages ZeroMemory(&r, sizeof(r)); GetClientRect(hwnd, &r); SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r); r.right -= r.left-1; r.bottom -= r.top-1; r.top += rtab.top; r.left += rtab.left; // Create the pages and position them in the tab control, but hide them pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc); pages[TAB_GAME] = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWINPAGE_GAME), hwndDlg, GamePageProc); pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES); SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); SetWindowPos(pages[TAB_GAME], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); // Tell the editfield acting as the console to exclude the width of the scrollbar GetClientRect(pages[TAB_MESSAGES],&r); r.right -= GetSystemMetrics(SM_CXVSCROLL)+4; r.left = r.top = 0; SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r); // Set a tab stop in the game data listbox { DWORD tabs[1] = { 150 }; ListBox_SetTabStops(GetDlgItem(pages[TAB_GAME], IDGDATA), 1, tabs); } SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START)); SetWindowText(hwndDlg, apptitle); } return FALSE; } case WM_NOTIFY: { LPNMHDR nmhdr = (LPNMHDR)lParam; int cur; if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break; cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0); switch (nmhdr->code) { case TCN_SELCHANGING: { if (cur < 0 || !pages[cur]) break; ShowWindow(pages[cur],SW_HIDE); return TRUE; } case TCN_SELCHANGE: { if (cur < 0 || !pages[cur]) break; ShowWindow(pages[cur],SW_SHOW); return TRUE; } } break; } case WM_CLOSE: if (mode == TAB_CONFIG) done = 0; else quitevent++; return TRUE; case WM_DESTROY: if (hbmp) { DeleteObject(hbmp); hbmp = NULL; } if (pages[TAB_GAME]) { DestroyWindow(pages[TAB_GAME]); pages[TAB_GAME] = NULL; } if (pages[TAB_CONFIG]) { DestroyWindow(pages[TAB_CONFIG]); pages[TAB_CONFIG] = NULL; } startupdlg = NULL; return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case WIN_STARTWIN_CANCEL: if (mode == TAB_CONFIG) done = 0; else quitevent++; return TRUE; case WIN_STARTWIN_START: done = 1; return TRUE; } return FALSE; case WM_CTLCOLORSTATIC: if ((HWND)lParam == pages[TAB_MESSAGES]) return (BOOL)GetSysColorBrush(COLOR_WINDOW); break; default: break; } return FALSE; }
CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Dialog((LPCSTR)IDD_DISASM, _hInstance, _hParent) { cpu = _cpu; lastTicks = CoreTiming::GetTicks(); keepStatusBarText = false; SetWindowText(m_hDlg, ConvertUTF8ToWString(_cpu->GetName()).c_str()); #ifdef THEMES //if (WTL::CTheme::IsThemingSupported()) //EnableThemeDialogTexture(m_hDlg ,ETDT_ENABLETAB); #endif int x = g_Config.iDisasmWindowX == -1 ? 500 : g_Config.iDisasmWindowX; int y = g_Config.iDisasmWindowY == -1 ? 200 : g_Config.iDisasmWindowY; int w = g_Config.iDisasmWindowW; int h = g_Config.iDisasmWindowH; // Start with the initial size so we have the right minimum size from the rc. SetWindowPos(m_hDlg, 0, x, y, 0, 0, SWP_NOSIZE); CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); ptr->setDebugger(cpu); ptr->gotoAddr(0x00000000); CtrlRegisterList *rl = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST)); rl->setCPU(cpu); GetWindowRect(m_hDlg, &defaultRect); //symbolMap.FillSymbolListBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION); symbolMap.FillSymbolComboBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION); GetWindowRect(GetDlgItem(m_hDlg, IDC_REGLIST), ®Rect); GetWindowRect(GetDlgItem(m_hDlg, IDC_DISASMVIEW), &disRect); GetWindowRect(GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST), &breakpointRect); GetWindowRect(GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST), &defaultBreakpointRect); HWND tabs = GetDlgItem(m_hDlg, IDC_LEFTTABS); TCITEM tcItem; ZeroMemory (&tcItem,sizeof (tcItem)); tcItem.mask = TCIF_TEXT; tcItem.dwState = 0; tcItem.pszText = L"Regs"; tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1; tcItem.iImage = 0; int result1 = TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); tcItem.pszText = L"Funcs"; tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1; int result2 = TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST), SW_NORMAL); ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), SW_HIDE); SetTimer(m_hDlg,1,1000,0); // subclass the goto edit box HWND editWnd = GetDlgItem(m_hDlg,IDC_ADDRESS); DefGotoEditProc = (WNDPROC)GetWindowLongPtr(editWnd,GWLP_WNDPROC); SetWindowLongPtr(editWnd,GWLP_WNDPROC,(LONG_PTR)GotoEditProc); // init memory viewer CtrlMemView *mem = CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW)); mem->setDebugger(_cpu); breakpointList = new CtrlBreakpointList(GetDlgItem(m_hDlg,IDC_BREAKPOINTLIST)); breakpointList->setCpu(cpu); breakpointList->setDisasm(ptr); breakpointList->reloadBreakpoints(); threadList = new CtrlThreadList(GetDlgItem(m_hDlg,IDC_THREADLIST)); threadList->reloadThreads(); stackTraceView = new CtrlStackTraceView(GetDlgItem(m_hDlg,IDC_STACKFRAMES)); stackTraceView->setCpu(cpu); stackTraceView->setDisasm(ptr); stackTraceView->loadStackTrace(); // init bottom "tab" changeSubWindow(SUBWIN_FIRST); // init status bar statusBarWnd = CreateStatusWindow(WS_CHILD | WS_VISIBLE, L"", m_hDlg, IDC_DISASMSTATUSBAR); if (g_Config.bDisplayStatusBar == false) { ShowWindow(statusBarWnd,SW_HIDE); } // Actually resize the window to the proper size (after the above setup.) if (w != -1 && h != -1) { // this will also call UpdateSize SetWindowPos(m_hDlg, 0, x, y, w, h, 0); } SetDebugMode(true, true); }
static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static HICON hIcon; TCHAR tmpbuf[MAX_PATH]; if (uMsg == WM_DESTROY && hIcon) { DeleteObject(hIcon); hIcon=0; } if (uMsg == WM_INITDIALOG || uMsg == WM_USER+1) { int backenabled=0,iscp=1,islp=1, x; struct { LPTSTR id; WNDPROC proc; LPTSTR s; } windows[4]= { {MAKEINTRESOURCE(IDD_LICENSE),LicenseProc,""}, {MAKEINTRESOURCE(IDD_SELCOM),LicenseProc,""}, {MAKEINTRESOURCE(IDD_DIR),DirProc,""}, {MAKEINTRESOURCE(IDD_INSTFILES),InstProc,""}, }; int messages[4] = { JAVAWS_MESSAGE_LICENSE, JAVAWS_MESSAGE_INSTOPT, JAVAWS_MESSAGE_INSTDIR, JAVAWS_MESSAGE_INSTFILES }; for( x=0; x<4; x++) { GETRESOURCE(tmpbuf, messages[x]); windows[x].s = (LPTSTR)malloc((_tcslen(tmpbuf) + 1) * sizeof(TCHAR)); _tcscpy(windows[x].s, tmpbuf); } if (uMsg == WM_INITDIALOG) { g_hwnd=hwndDlg; hIcon=LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_ICON2)); SetClassLong(hwndDlg,GCL_HICON,(long)hIcon); } if (m_curwnd) DestroyWindow(m_curwnd); if (!m_header->licensetext[0] || m_header->licensedata_offset==-1) islp=0; if (m_page==0 && !islp) m_page++; if (m_page==1 && autoinstall == 2) { /* skip the rest of the dialog because it's an autoinstall */ g_hwnd = NULL; EndDialog(hwndDlg,3); } if (m_header->num_sections < 2) iscp=0; { int id=LOWORD(wParam); if (uMsg==(WM_USER+1) && id==IDC_BACK) { if (m_page==1 && !iscp) m_page--; } else { if (m_page==1 && !iscp) m_page++; } } if (m_page==1&&islp) backenabled=1; if (m_page==2&&(islp||iscp)) backenabled=1; if (m_page < 0 || m_page > 3) { EndDialog(hwndDlg,0); } else { HWND hwnd; GETRESOURCE(tmpbuf,JAVAWS_BACK); SetDlgItemText(hwndDlg,IDC_BACK,tmpbuf); if (m_page==0) { GETRESOURCE(tmpbuf,JAVAWS_DECLINE); SetDlgItemText(hwndDlg,IDCANCEL,tmpbuf); GETRESOURCE(tmpbuf,JAVAWS_ACCEPT); SetDlgItemText(hwndDlg,IDOK,tmpbuf); hwnd=GetDlgItem(hwndDlg, IDC_BACK); ShowWindow(hwnd,SW_HIDE); } else { GETRESOURCE(tmpbuf,JAVAWS_CANCEL); SetDlgItemText(hwndDlg,IDCANCEL,tmpbuf); GETRESOURCE(tmpbuf,JAVAWS_NEXT); SetDlgItemText(hwndDlg,IDOK,tmpbuf); hwnd=GetDlgItem(hwndDlg, IDC_BACK); ShowWindow(hwnd,SW_SHOWNA); } { INT32 args[] = { (INT32)m_header->name, (INT32)windows[m_page].s }; m_curwnd=CreateDialog(g_hInstance,windows[m_page].id,hwndDlg,windows[m_page].proc); GETRESOURCE2(tmpbuf, JAVAWS_MESSAGE_SETUP2, args); SetWindowText(hwndDlg,tmpbuf); } } if (m_curwnd) { RECT r; GetWindowRect(GetDlgItem(hwndDlg,IDC_CHILDRECT),&r); ScreenToClient(hwndDlg,(LPPOINT)&r); SetWindowPos(m_curwnd,0,r.left,r.top,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER); ShowWindow(m_curwnd,SW_SHOWNA); EnableWindow(GetDlgItem(hwndDlg,IDC_BACK),backenabled); } } if (uMsg == WM_COMMAND) { int id=LOWORD(wParam); if (id == IDOK && m_curwnd) { m_page++; SendMessage(hwndDlg,WM_USER+1,wParam,0); } if (id == IDC_BACK && m_curwnd && m_page>0) { m_page--; SendMessage(hwndDlg,WM_USER+1,wParam,0); } if (id == IDCANCEL ) { if (m_abort) { EndDialog(hwndDlg,2); } else { EndDialog(hwndDlg,1); } } } return 0; }
HWND createWindow(HINSTANCE instance) { WNDCLASSEX wndClass; ZeroMemory(&wndClass,sizeof(WNDCLASSEX)); wndClass.cbSize = sizeof(WNDCLASSEX); wndClass.style = 0; wndClass.lpfnWndProc = windowProc; wndClass.hInstance = instance; wndClass.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(100)); wndClass.hCursor = LoadCursor(0,IDC_ARROW); wndClass.lpszClassName = "DBWRender"; if (RegisterClassEx(&wndClass) == 0) fatal("Could not create window class"); wnd = CreateWindowEx(WS_EX_CLIENTEDGE,"DBWRender","DBW Render Display", WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,0,0,width,height, 0,0,instance,0); if (wnd == 0) fatal("Could not create window"); NONCLIENTMETRICS ncm; ZeroMemory(&ncm,sizeof ncm); ncm.cbSize = sizeof ncm; SystemParametersInfo(SPI_GETNONCLIENTMETRICS,ncm.cbSize,&ncm,0); HFONT font = CreateFont(ncm.lfMessageFont.lfHeight,0,0,0,FW_NORMAL,0,0,0, ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH,ncm.lfMessageFont.lfFaceName); if (font == 0) fatal("Could not create font"); HDC dc = GetWindowDC(wnd); SIZE size; GetTextExtentPoint32(dc," Save ",8,&size); buttonWidth = size.cx; buttonHeight = (int)(1.25*size.cy); ReleaseDC(wnd,dc); createButton(instance,font,"&Save",IDC_SAVE,0); createButton(instance,font,"E&xit",IDC_QUIT,1); ACCEL accelt[2] = { { FALT,'s',IDC_SAVE }, { FALT,'x',IDC_QUIT }}; accel = CreateAcceleratorTable(accelt,2); if (accel == 0) fatal("Could not create accelerator table"); RECT wr, cr; GetWindowRect(wnd,&wr); GetClientRect(wnd,&cr); int w = width+(wr.right-wr.left)-(cr.right-cr.left); int h = height+buttonHeight+(wr.bottom-wr.top)-(cr.bottom-cr.top); int mw = GetSystemMetrics(SM_CXFULLSCREEN); int mh = GetSystemMetrics(SM_CYFULLSCREEN); int x = w < mw ? (mw-w)/2 : 0; int y = h < mh ? (mh-h)/2 : 0; MoveWindow(wnd,x,y,w,h,0); ShowWindow(wnd,SW_SHOW); return wnd; }