本文整理汇总了C++中GetWindowRect函数的典型用法代码示例。如果您正苦于以下问题:C++ GetWindowRect函数的具体用法?C++ GetWindowRect怎么用?C++ GetWindowRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetWindowRect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetWindowRect
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;
}
开发者ID:SBmore,项目名称:NSGame,代码行数:78,代码来源:Graphics2D.cpp
示例2: OnFunction
/*------------------------------------------------
"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);
}
}
开发者ID:k-takata,项目名称:TClockLight,代码行数:68,代码来源:pagemouse.c
示例3: dc
// 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);
}
开发者ID:arefinsaaad,项目名称:kupl09,代码行数:94,代码来源:ColourPopup.cpp
示例4: DlgProc
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);
//.........这里部分代码省略.........
开发者ID:Shondoit,项目名称:loader,代码行数:101,代码来源:loader.c
示例5: populate_insert_dlg
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;
}
开发者ID:pinchyCZN,项目名称:DB_UTIL,代码行数:76,代码来源:insert_row.c
示例6: CC_BREAK_IF
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;
}
开发者ID:524777134,项目名称:cocos2d-x,代码行数:66,代码来源:CCEGLView.cpp
示例7: SpltNs_WndProc
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);
//.........这里部分代码省略.........
开发者ID:sunmingbao,项目名称:xb-ether-tester,代码行数:101,代码来源:splitters.c
示例8: WindowY
int WindowY(HWND hWnd){
static RECT rc;
GetWindowRect(hWnd, &rc);
return (rc.top);
}
开发者ID:csersoft,项目名称:hard86,代码行数:5,代码来源:global.cpp
示例9: WindowProc
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;
}
开发者ID:DNeveroff,项目名称:WIN-API-,代码行数:89,代码来源:func_simple_window.cpp
示例10: WindowHeight
int WindowHeight(HWND hWnd){
static RECT rc;
GetWindowRect(hWnd, &rc);
return RectHeight(rc);
}
开发者ID:csersoft,项目名称:hard86,代码行数:5,代码来源:global.cpp
示例11: WindowX
int WindowX(HWND hWnd){
static RECT rc;
GetWindowRect(hWnd, &rc);
return (rc.left);
}
开发者ID:csersoft,项目名称:hard86,代码行数:5,代码来源:global.cpp
示例12: WindowWidth
int WindowWidth(HWND hWnd){
static RECT rc;
GetWindowRect(hWnd, &rc);
return RectWidth(rc);
}
开发者ID:csersoft,项目名称:hard86,代码行数:5,代码来源:global.cpp
示例13: updateSize
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);
}
开发者ID:DeejStar,项目名称:Jack-Claw,代码行数:63,代码来源:dialog.cpp
示例14: ParentWndProc
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)
{
//.........这里部分代码省略.........
开发者ID:abcsds,项目名称:pinguino-installers,代码行数:101,代码来源:nsisdl.cpp
示例15: SetIcon
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
}
开发者ID:Alrash,项目名称:BookTickets,代码行数:68,代码来源:BookTicketsDlg.cpp
示例16: PaintWorker
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);
}
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:mimplugins-svn,代码行数:101,代码来源:CLCButton.c
示例17: BaseBar_WindowProc
//.........这里部分代码省略.........
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);
}
开发者ID:now,项目名称:slackedit,代码行数:67,代码来源:pcp_basebar.c
示例18: TSButtonWndProc
//.........这里部分代码省略.........
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, T
|
请发表评论