- 再也不做站长了
-
用 SetWindowPos这个函数 (功能包括了MoveWindow这个函数)
你可以这样:
SetWindowPos(hWnd,HWND_TOPMOST,0,0,200,200,SWP_SHOWWINDOW);
窗口就移动到(0,0)的位置了
关于它的原型和说明:
The SetWindowPos function changes the size, position, and Z order of a child, pop-up, or top-level window. Child, pop-up, and top-level windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.
BOOL SetWindowPos(
HWND hWnd, // handle to window
HWND hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
UINT uFlags // window-positioning flags
);
Parameters
hWnd
Handle to the window.
hWndInsertAfter
Handle to the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values: Value Meaning
HWND_BOTTOM Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, the window loses its topmost status and is placed at the bottom of all other windows.
HWND_NOTOPMOST Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.
HWND_TOP Places the window at the top of the Z order.
HWND_TOPMOST Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
For more information about how this parameter is used, see the following Remarks section.
X
Specifies the new position of the left side of the window, in client coordinates.
Y
Specifies the new position of the top of the window, in client coordinates.
cx
Specifies the new width of the window, in pixels.
cy
Specifies the new height of the window, in pixels.
uFlags
Specifies the window sizing and positioning flags. This parameter can be a combination of the following values: Value Meaning
SWP_ASYNCWINDOWPOS If the calling thread does not own the window, the system posts the request to the thread that owns the window. This prevents the calling thread from blocking its execution while other threads process the request.
SWP_DEFERERASE Prevents generation of the WM_SYNCPAINT message.
SWP_DRAWFRAME Draws a frame (defined in the window"s class description) around the window.
SWP_FRAMECHANGED Sends a WM_NCCALCSIZE message to the window, even if the window"s size is not being changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window"s size is being changed.
SWP_HIDEWINDOW Hides the window.
SWP_NOACTIVATE Does not activate the window. If this flag is not set, the window is activated and moved to the top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter parameter).
SWP_NOCOPYBITS Discards the entire contents of the client area. If this flag is not specified, the valid contents of the client area are saved and copied back into the client area after the window is sized or repositioned.
SWP_NOMOVE Retains the current position (ignores the X and Y parameters).
SWP_NOOWNERZORDER Does not change the owner window"s position in the Z order.
SWP_NOREDRAW Does not redraw changes. If this flag is set, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of the window being moved. When this flag is set, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing.
SWP_NOREPOSITION Same as the SWP_NOOWNERZORDER flag.
SWP_NOSENDCHANGING Prevents the window from receiving the WM_WINDOWPOSCHANGING message.
SWP_NOSIZE Retains the current size (ignores the cx and cy parameters).
SWP_NOZORDER Retains the current Z order (ignores the hWndInsertAfter parameter).
SWP_SHOWWINDOW Displays the window.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, callGetLastError.
Remarks
If the SWP_SHOWWINDOW or SWP_HIDEWINDOW flag is set, the window cannot be moved or sized.
If you have changed certain window data using SetWindowLong, you must call SetWindowPos to have the changes take effect. Use the following combination for uFlags: SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED.
A window can be made a topmost window either by setting the hWndInsertAfter parameter to HWND_TOPMOST and ensuring that the SWP_NOZORDER flag is not set, or by setting a window"s position in the Z order so that it is above any existing topmost windows. When a non-topmost window is made topmost, its owned windows are also made topmost. Its owners, however, are not changed.
If neither the SWP_NOACTIVATE nor SWP_NOZORDER flag is specified (that is, when the application requests that a window be simultaneously activated and its position in the Z order changed), the value specified in hWndInsertAfter is used only in the following circumstances:
Neither the HWND_TOPMOST nor HWND_NOTOPMOST flag is specified in hWndInsertAfter.
The window identified by hWnd is not the active window.
An application cannot activate an inactive window without also bringing it to the top of the Z order. Applications can change an activated window"s position in the Z order without restrictions, or it can activate a window and then move it to the top of the topmost or non-topmost windows.
If a topmost window is repositioned to the bottom (HWND_BOTTOM) of the Z order or after any non-topmost window, it is no longer topmost. When a topmost window is made non-topmost, its owners and its owned windows are also made non-topmost windows.
A non-topmost window can own a topmost window, but the reverse cannot occur. Any window (for example, a dialog box) owned by a topmost window is itself made a topmost window, to ensure that all owned windows stay above their owner.
If an application is not in the foreground, and should be in the foreground, it must call the SetForegroundWindow function.
Windows CE: If this is a visible top-level window, and the SWP_NOACTIVATE flag is not specified, this function will activate the window. If this is the currently active window, and either the SWP_NOACTIVATE flag or the SWP_HIDEWINDOW flag is specified, the activation is passed on to another visible top-level window.
When you set the SWP_FRAMECHANGED flag in the nFlags parameter to this function, Windows CE redraws the entire non-client area of the window, which may change the size of the client area. This is the only way to get the non-client area to be recalculated and is typically used after a you"ve changed the window style by calling SetWindowLong.
SetWindowPos will always cause a WM_WINDOWPOSCHANGED message to be sent to the window. The flags passed in this message are exactly the same as those passed into the function. No other messages are sent by this function.
Windows CE 1.0 does not support the HWND_TOPMOST and HWND_NOTOPMOST constants in the hwndInsertAfter parameter.
Windows CE 1.0 does not support the SWP_DRAWFRAME or SWP_NOCOPYBITS flags in the fuFlags paramete.
- 铁血嘟嘟
-
你回答的好无聊!
- 黑桃花
-
移呀
在VC++如何使控件大小修改为规定的大小?
选中控件,你按shift+F7看看是不是大小变合适了。2023-07-23 19:34:468
MoveWindow和setwindowpos的区别
你好,区别如下:要区分MoveWindow和setwindowpos的区别,我们先从msdn上入手:1、MoveWindowThis function changes the position and dimensions of the specified window. For a top-level window, the position and dimensions are relative to the upper-left corner of the screen. For a child window, they are relative to the upper-left corner of the parent window"s client area.BOOL MoveWindow( HWND hWnd, int X, int Y, int nWidth, int nHeight, BOOL bRepaint ); MoveWindow sends WM_WINDOWPOSCHANGED, WM_MOVE, WM_SIZE, and WM_NCCALCSIZE messages to the window. (这里很重要,说明MoveWindow函数内部不做真实的窗口处理,而是发送了一组消息,让其他函数进行处理,其实这个函数就是SetWindowPos,我们可以继续往下看)2、SetWindowPosThis function changes the size, position, and z-order of a child, pop-up, or top-level window. Child, pop-up, and top-level windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the z-order.BOOL SetWindowPos( HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags ); SetWindowPos always causes a WM_WINDOWPOSCHANGED message to be sent to the window. The flags passed in this message are exactly the same as those passed into the function. No other messages are sent by this function. (SetWindowPos包含了z-order的设置,其功能比MoveWindow更为强大,包含了一组设置窗口显示状态的标志。然而,MoveWindow和SetWindowPos更本质的区别是,MoveWindow做了更多额外的事情,发送WM_MOVE, WM_SIZE, and WM_NCCALCSIZE等多种消息给窗口,而SetWindowPos则显的单纯的多,只发送了WM_WINDOWPOSCHANGED消息给窗口)从上面可以看出MoveWindow和SetWindowPos实现的功能基本是一致的,但还是存在细微的差别,关键的一点是MoveWindow不仅通知窗口进行SetWindowPos操作,而且还发送了一批消息,告知窗口显示改变了,这样窗口就可以在内部进行一些操作。这点对处理ActiveX控件的resize很重要,在ActiveX控件中往往通过WM_SIZE消息处理关联窗口resize的窗口调整,所以在调用方必须使用MoveWindow才能使ActiveX控件实现resize。2023-07-23 19:35:061
VC++中如何用movewindow实现图片移动
MoveWindow是用来移动或改变1个窗口、控件的大小,如果你的图片是用控件显示的,那就能够用GetDlgItem传入图片控件的ID,作为MoveWindow的第1个参数,然后设置其他位置参数便可。2023-07-23 19:35:172
让物体移动到指定位置要用什么函数
函数(function清末根据日语翻译+英语读音译为“方程”),名称出自数学家李善兰的著作《代数学》。之所以如此翻译,他给出的原因是“凡此变数中函彼变数者,则此为彼之函数”,也即函数指一个量随着另一个量的变化而变化,或者说一个量中包含另一个量。2023-07-23 19:35:302
c++ MoveWindow怎么用
MoveWindow是C++MFC库函数,你要库函数的源代码么?2023-07-23 19:35:433
C语言MoveWindow的用法?
#001 //#002 // 响应命令.#003 // #004 //#005 LRESULT CCaiWinMsg::OnCommand(int nID,int nEvent)#006 { #007 // 菜单选项命令响应:#008 switch (nID)#009 {#010 case IDC_CREATEBTN:#011 //显示一个按钮。#012 if (!m_hBtn)#013 {#014 m_hBtn = CreateWindow(_T("BUTTON"),_T("按钮"),#015 WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,#016 50,50,100,32,#017 m_hWnd,(HMENU)IDC_BTN,m_hInstance,NULL);#018 } #019 break;#020 case IDC_BTN: #021 OutputDebugS www.hnnedu.com tring(_T("按钮按下 "));#022 {#023 static bool bChangeText = true;#024 if (bChangeText)#025 {#026 //设置按钮的文字。#027 SetWindowText(m_hBtn,_T("改变它"));#028 #029 //改变按钮窗口的位置和大小。#030 MoveWindow(m_hBtn,10,10,100,32,TRUE);#031 }#032 else#033 {#034 //设置按钮的文字。#035 SetWindowText(m_hBtn,_T("按钮"));#036 #037 //改变按钮窗口的位置和大小。#038 MoveWindow(m_hBtn,50,50,100,32,TRUE);#039 }#040 #041 //每一次都改变。#042 bChangeText = !bChangeText; #043 }#044 break;#045 default:#046 return CCaiWin::OnCommand(nID,nEvent);#047 }#048 #049 return 1;#050 }2023-07-23 19:35:541
c++如何实现让窗口抖动
MoveWindow( HWND hWnd, int X, int Y, int nWidth, int nHeight, BOOL bRepaint );有规律移动几次!2023-07-23 19:36:041
VC中基于对话框的编程如何改变按钮位置?
改变按钮位置GetDlgItem(按钮ID)->MoveWindow(rectPos);rectPos是CRect型的变量,代表按钮要移动到的位置。也可以直接填数字MoveWindow的原型如下:BOOLMoveWindow(HWNDhWnd,//handletowindowintX,//horizontalpositionintY,//verticalpositionintnWidth,//widthintnHeight,//heightBOOLbRepaint//repaintflag);改变编辑框内容GetDlgItem(编辑框ID)->SetWindowText("新内容");2023-07-23 19:36:121
vc编程中如何改变系统对话框的标题??
改变按钮位置getdlgitem(按钮id)->movewindow(rectpos);rectpos是crect型的变量,代表按钮要移动到的位置。也可以直接填数字movewindow的原型如下:boolmovewindow(hwndhwnd,//handletowindowintx,//horizontalpositioninty,//verticalpositionintnwidth,//widthintnheight,//heightboolbrepaint//repaintflag);改变编辑框内容getdlgitem(编辑框id)->setwindowtext("新内容");2023-07-23 19:36:232
win32 禁止使用MoveWindow改变窗口大小
如果发现窗口大小被改变 则马上变回去 = = 别理我我是来逗比的2023-07-23 19:36:342
用同一个坐标rect,用同一个函数MoveWindow(&rect)为什么会把窗口移动到不同的地方?
void CWnd::MoveWindow( LPCRECT lpRect, BOOL bRepaint = TRUE );lpRectCRect对象或RECT结构,指定了新的大小和位置。说明这个函数改变窗口的位置和大小。对于顶层的CWnd对象,x和y参数是相对于屏幕的左上角的。对于子对象,它们是相对于父窗口客户区的左上角的。2023-07-23 19:37:011
易语言将窗口移动到指定位置怎么写
【窗口名称】.移动(,,,)图片是要完全一样还是相似度?2023-07-23 19:37:184
VC++MFC 怎么设置初始化窗体的位置?
简单的说可以在OnInitDialog()函数里加上一句:RECT rect;GetClientRect(&rect);MoveWindow(1024-rect.right,0,rect.right,rect.bottom);以上MoveWindow中的前两个参数就是窗体显示时的左上角坐标,我假设你的屏幕分辨率为1024*768,所以其横坐标为1024-rect.right;2023-07-23 19:37:411
MoveWindow 和SetWindowPos 修改窗口大小问题
不知道为什么一定要用消息。实在要用消息,就使用自定义的消息。在自定义 的消息处理函数里,再使用MoveWindow或者SetWindowPos来修改窗口大小。2023-07-23 19:37:482
C++中如何自由改变客户区大小?
响应WM_NCCALCSIZE可改变nc区的大小.关键在于lParam,msdn上说当wParam为True时, lParam为LPNCCALCSIZE_PARAMS的指定,当wParam为False时为LPRECT,做了些实验发现 只有第一次时wParam为False,LPNCCALCSIZE_PARAMS的语义相当复杂,不过我们只用 看第一个RECT就成.它表是窗口客户区的大小.当lParam为LPRECT时,也同样.只用改变 客户区的大小,相应的就改变了非客户区的大小.2023-07-23 19:37:573
vb中,如何在运行时用鼠标对控件(如Textbox)进行移动和缩放(即改变大小)操作?
Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Const WM_SYSCOMMAND = &H112 Const SC_MOVE = &HF010& Const HTCAPTION = 2 Private Sub MoveWindow(ByVal hwnd As Long)Dim ret As LongReleaseCaptureret = SendMessage(Text1.hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0) End Sub Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) MoveWindow hwnd End SubPrivate Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) MoveWindow hwnd End Sub2023-07-23 19:38:131
MFC拖动一个对话框其他的对话框跟着动?
添加主对框的OnMove响应函数在函数中利用MoveWindow或SetWindowPos函数移动你创建的窗体void CMainDlg::OnMove(int x, int y) {//x,y是当前主对话框的左上角坐标,可根据此坐标调整位置if (IsWindow(m_dlgMy.m_hWnd)) { CRect rtMyDlg; m_dlgMy.GetWindowRect(&rtMyDlg); m_dlgMy.MoveWindow(x+100,y+100,rtMyDlg.Width(),rtMyDlg.Height()); 或直接 m_dlgMy.SetWindowPos(this,x+100,y+100,0,0,SWP_NOSIZE);}}这里 x+100 只是演示 根据自己情况调整2023-07-23 19:38:201
子对话框 GetClientRect函数 得到的值为什么不一样
应该是整除除不尽造成的吧2023-07-23 19:38:283
窗口怎么移动
问题一:怎样用键盘控制窗口移动 1.按下Alt+打开窗口的控制菜单。 2.移动光标键选定“移动”命令后按回车键,则鼠标指针变成4个箭头的形状。 3.用光标移动键移动窗口。 4.认为窗口的位置合适后按回车键。 5.Alt+Tab,选择要移动的窗口,如果是最大化的情况下,先Alt+空格,再按 R 来恢复窗口。再按 Alt+空格 再按M,就可以用方向键来移动了。 问题二:网页窗口移动怎么设置 就和移动图片一样,左键按住拖动就可以了,360和IE9都是这样的 问题三:win7怎么移动窗口 不要用win7了 问题四:电脑怎么移动窗口 你是想让 口 变小吗 ? 那 先点击 右上角的 向下还原 然后鼠标放在窗口边缘 大小随意拉动 问题五:DNF窗口怎么移动? 把鼠标 放在 DNF 窗口的最上方。、。。然后按住 就可以拖动。。。不过只有在城镇中 *** 则频道的时候可以移动 问题六:如何用键盘移动对话框 键盘上有左右上下键,结合TAB键或ALT键就可以了,不知道你是哪种情况,先试试看 问题七:如何移动电脑开始栏位置 用鼠标有点叮务栏空白的地方 把锁定任务栏上的对号去掉 让它前面没有对号 然后用鼠标左键点住任务栏拖动就可以了 想拖到哪边都可以 拖动好以后 再锁定任务栏 然后它就不会乱跑了 问题八:cad怎么移动窗口? 鼠标中键按住拖动视口,中键滑轮缩放视口 问题九:在win7里如何拖动窗口 不激拖到靠边,win7有个功能是窗口靠边会自动调整. 如果不习惯可以关闭这个功能 禁用方法: 1.打开”开始菜单”> 进入”控制面板”>点击 “轻松访问”>点击 “更改鼠标的工作方式” 2.找到 “更便于管理窗口” 一栏 > 勾选 “防止将窗口移动到屏幕时自动排列窗口”一项 > 点击”应用” “确定” 设置完成 问题十:c++如何动态移动窗口 这样试试: if(hwnd) ::MoveWindow(hwnd, 200, 200, 200, 200, TRUE); 追问: 这个是改动目标窗口了啊,大大.. 我最近在看一个搞笑的视频,想把它录下来传给朋友,但是这个视频有水印,我想写个程序,使自己的窗口永远遮挡在那个水印上面,而int *pbx,*pby;,就是这个水印的X,Y轴.. 请问大大,能有什么方法实现吗? 回答: ::MoveWindow(hwnd, *pbx, *pby, 200, 200, TRUE);这样可以吗 补充: 不好意思,看错题了,原来是移动自己的窗体啊,那就这样: ::MoveWindow(m_hWnd, *pbx, *pby, 200, 200, TRUE); 追问: 这样不行啊,这样就直接操作目标窗口了啊,而不是自己的窗口了,如果把hwnd替换成自己的窗口句柄就可以操作自己的窗口了吗?还有就是我的窗口是没有标题的那种,,请问大大,,我该怎么获取我自己的窗口句柄啊?就这一个问题了,麻烦大大了.. 回答: m_hWnd 这个就是你自己窗体的句柄,或者 GetSafeHwnd()2023-07-23 19:38:361
vb中,如何在运行时用鼠标对控件(如Textbox)进行移动和缩放(即改变大小)操作?
Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Const WM_SYSCOMMAND = &H112 Const SC_MOVE = &HF010& Const HTCAPTION = 2 Private Sub MoveWindow(ByVal hwnd As Long)Dim ret As LongReleaseCaptureret = SendMessage(Text1.hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0) End Sub Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) MoveWindow hwnd End SubPrivate Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) MoveWindow hwnd End Sub2023-07-23 19:38:561
怎样用VB写移动文本框
这是通过鼠标移动代码:PrivateDeclareFunctionReleaseCaptureLib"user32"()AsLongPrivateDeclareFunctionSendMessageLib"user32"Alias"SendMessageA"(ByValhwndAsLong,ByValwMsgAsLong,ByValwParamAsLong,lParamAsAny)AsLongConstWM_SYSCOMMAND=&H112ConstSC_MOVE=&HF010&ConstHTCAPTION=2PrivateSubMoveWindow(ByValhwndAsLong)DimretAsLongReleaseCaptureret=SendMessage(Text1.hwnd,WM_SYSCOMMAND,SC_MOVE+HTCAPTION,0)EndSubPrivateSubText1_MouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)MoveWindowhwndEndSubPrivateSubText1_MouseMove(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)MoveWindowhwndEndSub当然你可以通过时钟控制dimiasintegerprivatesubform_load()timer1.interval=100endsubprivatesubtimer1_timer()i=i+1textbox1.top+=1endsub这里只做了,一个方向移动,你可以类推,还有加上到端的判断!!希望对你有帮助!2023-07-23 19:39:051
VB 拖动picture 里的图片
添加两个picture控件,picture1和picture2代码:Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongConst WM_SYSCOMMAND = &H112Const SC_MOVE = &HF010&Const HTCAPTION = 2Private Sub MoveWindow(ByVal hwnd As Long)Dim ret As LongReleaseCaptureret = SendMessage(Picture2.hwnd, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0)End SubPrivate Sub Form_Load()With Picture2.Left = Picture1.Left.Top = Picture1.Top.Height = Picture1.Height.Width = Picture1.WidthEnd WithPicture2.Picture = Picture1.PictureEnd SubPrivate Sub Picture2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)MoveWindow hwndPicture1.Picture = LoadPicture("")End SubPrivate Sub Picture2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)MoveWindow hwndEnd Sub"最后加一句,好像你这样做没什么意思2023-07-23 19:39:153
易语言 修改指定窗口位置
.版本2.子程序窗口移动,,公开,移动指定窗口(无返回值).参数临时句柄,整数型,,欲移动窗口的句柄.参数窗口新左边,整数型,可空,可空:原左边不变.参数窗口新顶边,整数型,可空,可空:原顶边不变.参数窗口新宽度,整数型,可空,可空:原宽度不变.参数窗口新高度,整数型,可空,可空:原高度不变.局部变量位置大小,矩形坐标_窗口取外边框(临时句柄,位置大小).如果真(是否为空(窗口新左边))窗口新左边=位置大小.矩形左边.如果真结束.如果真(是否为空(窗口新顶边))窗口新顶边=位置大小.矩形顶边.如果真结束.如果真(是否为空(窗口新宽度))窗口新宽度=位置大小.矩形右边-位置大小.矩形左边.如果真结束.如果真(是否为空(窗口新高度))窗口新高度=位置大小.矩形底边-位置大小.矩形顶边.如果真结束_移动窗口(临时句柄,窗口新左边,窗口新顶边,窗口新宽度,窗口新高度,1).版本2.DLL命令_窗口取外边框,逻辑型,,"GetWindowRect",公开,user32.dll获得整个窗口的范围矩形,窗口的边框、标题栏、滚动条及菜单等都在这个矩形内.参数句柄,整数型,,Long,想获得范围矩形的那个窗口的句柄.参数大小,矩形坐标,传址,RECT,屏幕坐标中随同窗口装载的矩形(左边,顶边,右边,底边).DLL命令_移动窗口,整数型,,"MoveWindow",,user32.dll.参数hwnd,整数型,,备注1无法读取,请您提供该API名报易BBS中ID号klasp完善。.参数x,整数型,,备注2无法读取,请您提供该API名报易BBS中ID号klasp完善。.参数y,整数型,,备注3无法读取,请您提供该API名报易BBS中ID号klasp完善。.参数n,整数型,,备注4无法读取,请您提供该API名报易BBS中ID号klasp完善。.参数nHeight,整数型,,备注5无法读取,请您提供该API名报易BBS中ID号klasp完善。.参数bRepaint,整数型,,备注6无法读取,请您提供该API名报易BBS中ID号klasp完善。.版本2.数据类型矩形坐标,公开.成员矩形左边,整数型.成员矩形顶边,整数型.成员矩形右边,整数型.成员矩形底边,整数型下面是设置窗口状态的API:.版本2.DLL命令设置窗口状态,整数型,,"ShowWindow",,控制窗口的状态(在vb里使用:针对vb窗体及控件,请使用对应的vb属性)成功:返回TRUE(非零),失败:返回FALSE(零).参数hwnd,整数型,,窗口句柄,要向这个窗口应用由命令.参数nCmdShow,整数型,,为窗口指定的一个命令。请用下述任何一个常数:0隐藏窗口1显示窗口2最小化激活3最大化激活4还原6最小化取消激活7最小化9还原激活2023-07-23 19:39:221
C语言如何从代码变成软件,如何变成带有按钮的对话框软件?
如果你要编写Windows上面的程序,那么可以学习WindowsAPI。什么叫API?就是应用程序接口。他是一个函数库,已经定义好了的函数,你要做的只是用其他语言调用这些函数,比如C、C++。为什么可以用C编写Windows程序,也可以用C++?原因就在于此。说直观点,在WindowsAPI中有一系列的函数,用于文件管理、内存管理、进程、消息机制等等。比如MessageBox就是一个输出消息的函数。你编译以下代码,最后生成exe的可执行文件,双击看看,就是一个简单的消息窗口。#include <windows.h>#pragma comment (lib, "User32.lib")int WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ){ // 调用API函数 MessageBox MessageBox(NULL, TEXT("开始学习Windows编程"), TEXT("消息对话框"), MB_OK); return 0;}关于API的书籍很多,你搜Windows编程或者WindowsAPI就行了,我这就不打广告了。至于MFC,是以C++类的形式封装了Windows的API。可以简化工作。 不过还是建议从API学起,因为它才是基础,才能让你了解这个功能到底是怎么实现的。2023-07-23 19:39:322
在MFC中怎么样让控件的大小随着主窗体大
mfc 窗口大小变化时让窗口内部控件也一起随比例改变位置:void CXTest2Dlg::OnSize(UINT nType, int cx, int cy){CDialog::OnSize(nType, cx, cy);// TODO: 在此处添加消息处理程序代码//将窗口移动到合适位置和大小CRect rc,rc0,rc1;GetClientRect(&rc0);//先取得整个对话框的大小及位置//设置Tab控件位置rc1.top=rc0.top;rc1.left=rc0.left+1;rc1.bottom=rc0.bottom-30;rc1.right=rc0.right-1;if(GetDlgItem(IDC_TAB1)!=NULL){GetDlgItem(IDC_TAB1)->MoveWindow(&rc1);}//设置时钟位置rc1.top=rc0.bottom-20;rc1.left=rc0.left+5;rc1.bottom=rc0.bottom;rc1.right=rc0.left+160;if(GetDlgItem(IDC_CLOCKTEST)!=NULL){GetDlgItem(IDC_CLOCKTEST)->MoveWindow(&rc1);}//设置关闭按钮位置rc1.top=rc1.top-5;rc1.left=rc0.right-200;rc1.bottom=rc1.bottom;rc1.right=rc0.right-120;if(GetDlgItem(IDOK)!=NULL){GetDlgItem(IDOK)->MoveWindow(&rc1);}//设置取消按钮位置rc1.left=rc0.right-100;rc1.right=rc0.right-20;if(GetDlgItem(IDCANCEL)!=NULL){GetDlgItem(IDCANCEL)->MoveWindow(&rc1);}//将三个对话框资源定位到Tab控件中if(GetDlgItem(IDC_TAB1)!=NULL){GetDlgItem(IDC_TAB1)->GetClientRect(&rc);rc1.top=rc.top+20;rc1.left=rc.left+1;rc1.bottom=rc.bottom-10;rc1.right=rc.right-1;tab1.GetClientRect(&rc1);tab1.GetDlgItem(IDC_MSGINFO)->MoveWindow(&rc1);//移动第一个 rc1.bottom=rc.bottom-35;//第二个及第三个底部留出按钮位置 tab2.GetDlgItem(IDC_BNSLIST)->MoveWindow(&rc1); tab3.GetDlgItem(IDC_MSGERRINFO)->MoveWindow(&rc1);2023-07-23 19:39:391
VC 如何设定对话框的大小
你这个是删除类,不是删除对话框,删除对话框就是直接按delete就可以了。删除类的方法是:先在solution那里,把你要删除的头文件和源文件删除,就是一个类要删除2个,一个是.h,一个是.cpp,之后再到文件夹删除你刚才删除的文件。这样就可以了。至于你说先删除文件夹的,那也可以,但还得在solution删。弄好了记得帮我加分。2023-07-23 19:39:533
VB API函数移动窗口
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function MoveWindow Lib "user32" Alias "MoveWindow" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long 说明 Dim hTMainForm as long "找句柄hTMainForm = FindWindow("", "(游戏的标题)")movewindow hTMainForm,0(窗口新的左侧位置),0(窗口新的顶部位置),1000(长),1000(宽),12023-07-23 19:40:072
怎么用易语言控制外部窗口的位置啊!
.版本 2.子程序 窗口_置位置和大小, 逻辑型, 公开, 修改窗口的位置和大小;.参数 窗口句柄, 整数型, , 欲改变位置和大小的窗口句柄.参数 顶边位置, 整数型, 可空, 窗口新的顶边位置,留空不变;.参数 左边位置, 整数型, 可空, 窗口新的左边位置,留空不变;.参数 新高度, 整数型, 可空, 窗口的高宽度,留空不变;.参数 新宽度, 整数型, 可空, 窗口的新宽度,留空不变;模块:精易模块, 官方论坛可以下载2023-07-23 19:40:185
MFC中TabCtrl控件怎么随着窗体的大小变化而变化?
这有个MFC tabctrl的例子,当窗口执行WM_SIZE时,改变tabctrl的大小即可,用MoveWindow.http://www.codeproject.com/Articles/93521/MultiPaneCtrl2023-07-23 19:40:572
如何从MFC中获取dialog窗体的宽度及大小等信息?
在哪里想获得了直接调用入校函数就可以了CRect rc;GetWindowRect(&rc);rc.Width();获得宽度rc.Height();获得高度2023-07-23 19:41:071
如何取窗口坐标的问题
.支持库 EdirectX.程序集 窗口程序集1.程序集变量 窗口句柄, 整数型.程序集变量 a, 矩形.子程序 _按钮1_被单击窗口句柄 = 寻找顶级窗口_ (“”, “”)取窗口矩形_ (窗口句柄, a)改变窗口_ (窗口句柄, 0, 0, a.右边 - a.左边, a.底边 - a.顶边, 1).版本 2.支持库 EdirectX.DLL命令 寻找顶级窗口_, 整数型, "user32.dll", "FindWindowA", , , FindWindow,寻找窗口列表中第一个符合指定条件的顶级窗口 .参数 窗口类名, 文本型, , lpClassName,参见相关帮助 .参数 窗口文本, 文本型, , lpWindowName,参见相关帮助.DLL命令 取窗口矩形_, 整数型, "user32", "GetWindowRect" .参数 窗口句柄, 整数型 .参数 矩形区域, 矩形.DLL命令 改变窗口_, 整数型, "user32.dll", "MoveWindow" .参数 窗口句柄, 整数型, , hwnd,欲移动窗口的句柄 .参数 左侧位置, 整数型, , x,窗口新的左侧位置 .参数 顶部位置, 整数型, , y,窗口新的顶部位置 .参数 新宽度, 整数型, , nWidth,窗口的新宽度 .参数 高宽度, 整数型, , nHeight,窗口的高宽度2023-07-23 19:41:241
bad argument list for function:movewindow是什么意思
movewindow这个函数的参数不正确,可能是你调用该函数时,参数个数和函数声明不一样,或者参数类型没匹配。你检查你这个函数的参数。2023-07-23 19:41:311
如何实现vc6按钮的自动排列
怎么说呢vc有自动排列的工具,可以排列,调整大小你转到资源编辑状态,vc的状态栏(底部)上面一点有一排按钮,选中你要排列的按钮,按那一排上的按钮进行调整如果看不见请留下qq号码,我告诉你初始化时,按钮对象使用MoveWindow函数举例,一个CButtonx;//这个x是在.h中定义的...x.MoveWindow(0,0,10,20,TRUE);//0,0是相对客户区左上角的位置,10是宽,20是高2023-07-23 19:41:391
C++怎么移动按钮位置
m_quit.GetWindowRect(&rect);换成m_quit.GetClientRect(&rect);2023-07-23 19:41:461
易语言如何修改别的窗口图标?
运行着好像不能2023-07-23 19:42:094
C语言Win32如何更改系统菜单
wxdevcpp example wintest 稍微改了一下,用GetSystemMenu 和AppendMenu处理WM_SYSCOMMAND消息 用MessageBox/** A basic example of Win32 programmiwng in C.** This source code is in the PUBLIC DOMAIN and has NO WARRANTY.** Colin Peters <colin@bird.fu.is.saga-u.ac.jp>*/#include <windows.h>#include <string.h>#include <iostream>#define IDM_ABOUT 1000 /*********资源ID 定义*****//** This is the window function for the main window. Whenever a message is* dispatched using DispatchMessage (or sent with SendMessage) this function* gets called with the contents of the message.*/LRESULT CALLBACKMainWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam){/* The window handle for the "Click Me" button. */static HWND hwndButton = 0;static int cx, cy;/* Height and width of our button. */HDC hdc;/* A device context used for drawing */PAINTSTRUCT ps;/* Also used during window drawing */RECT rc;/* A rectangle used during drawing *//** Perform processing based on what kind of message we got.*/switch (nMsg){case WM_CREATE:{/* The window is being created. Create our button* window now. */TEXTMETRIC tm;/***************看这里************/{HMENU hSysMenu = GetSystemMenu(hwnd, FALSE);AppendMenu(hSysMenu, MF_STRING, IDM_ABOUT, TEXT("关于"));}/***************************//* First we use the system fixed font size to choose* a nice button size. */hdc = GetDC (hwnd);SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT));GetTextMetrics (hdc, &tm);cx = tm.tmAveCharWidth * 30;cy = (tm.tmHeight + tm.tmExternalLeading) * 2;ReleaseDC (hwnd, hdc);/* Now create the button */hwndButton = CreateWindow ("button",/* Builtin button class */"Click Here",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,0, 0, cx, cy,hwnd,/* Parent is this window. */(HMENU) 1,/* Control ID: 1 */((LPCREATESTRUCT) lParam)->hInstance,NULL);return 0;break;}case WM_DESTROY:/* The window is being destroyed, close the application* (the child button gets destroyed automatically). */PostQuitMessage (0);return 0;break;case WM_PAINT:/* The window needs to be painted (redrawn). */hdc = BeginPaint (hwnd, &ps);GetClientRect (hwnd, &rc);/* Draw "Hello, World" in the middle of the upper* half of the window. */rc.bottom = rc.bottom / 2;DrawText (hdc, "Hello, World!", -1, &rc,DT_SINGLELINE | DT_CENTER | DT_VCENTER);EndPaint (hwnd, &ps);return 0;break;case WM_SIZE:/* The window size is changing. If the button exists* then place it in the center of the bottom half of* the window. */if (hwndButton &&(wParam == SIZEFULLSCREEN ||wParam == SIZENORMAL)){rc.left = (LOWORD(lParam) - cx) / 2;rc.top = HIWORD(lParam) * 3 / 4 - cy / 2;MoveWindow (hwndButton,rc.left, rc.top, cx, cy, TRUE);}break;/*********再看这******************/case WM_SYSCOMMAND:/* Check the control ID, notification code and* control handle to see if this is a button click* message from our child button. */if (wParam == IDM_ABOUT){MessageBox (NULL, "About..." , "messagebox关于菜单", 1);}elsereturn DefWindowProc (hwnd, nMsg, wParam, lParam);return 0;break;/***************************/case WM_COMMAND:/* Check the control ID, notification code and* control handle to see if this is a button click* message from our child button. */if (LOWORD(wParam) == 1 &&HIWORD(wParam) == BN_CLICKED &&(HWND) lParam == hwndButton){/* Our button was clicked. Close the window. */DestroyWindow (hwnd);}return 0;break;}/* If we don"t handle a message completely we hand it to the system* provided default window function. */return DefWindowProc (hwnd, nMsg, wParam, lParam);}int STDCALLWinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow){HWND hwndMain;/* Handle for the main window. */MSG msg;/* A Win32 message structure. */WNDCLASSEX wndclass;/* A window class structure. */char*szMainWndClass = "WinTestWin";/* The name of the main window class *//** First we create a window class for our main window.*//* Initialize the entire structure to zero. */memset (&wndclass, 0, sizeof(WNDCLASSEX));/* This class is called WinTestWin */wndclass.lpszClassName = szMainWndClass;/* cbSize gives the size of the structure for extensibility. */wndclass.cbSize = sizeof(WNDCLASSEX);/* All windows of this class redraw when resized. */wndclass.style = CS_HREDRAW | CS_VREDRAW;/* All windows of this class use the MainWndProc window function. */wndclass.lpfnWndProc = MainWndProc;/* This class is used with the current program instance. */wndclass.hInstance = hInst;/* Use standard application icon and arrow cursor provided by the OS */wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);/* Color the background white */wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);/** Now register the window class for use.*/RegisterClassEx (&wndclass);/** Create our main window using that window class.*/hwndMain = CreateWindow (szMainWndClass,/* Class name */"Hello",/* Caption */WS_OVERLAPPEDWINDOW,/* Style */CW_USEDEFAULT,/* Initial x (use default) */CW_USEDEFAULT,/* Initial y (use default) */CW_USEDEFAULT,/* Initial x size (use default) */CW_USEDEFAULT,/* Initial y size (use default) */NULL,/* No parent window */NULL,/* No menu */hInst,/* This program instance */NULL/* Creation parameters */);/** Display the window which we just created (using the nShow* passed by the OS, which allows for start minimized and that* sort of thing).*/ShowWindow (hwndMain, nShow);UpdateWindow (hwndMain);/** The main message loop. All messages being sent to the windows* of the application (or at least the primary thread) are retrieved* by the GetMessage call, then translated (mainly for keyboard* messages) and dispatched to the appropriate window procedure.* This is the simplest kind of message loop. More complex loops* are required for idle processing or handling modeless dialog* boxes. When one of the windows calls PostQuitMessage GetMessage* will return zero and the wParam of the message will be filled* with the argument to PostQuitMessage. The loop will end and* the application will close.*/while (GetMessage (&msg, NULL, 0, 0)){TranslateMessage (&msg);DispatchMessage (&msg);}return msg.wParam;}2023-07-23 19:42:211
C语言中的MoveWindow函数如何使用
#001 //#002 // 响应命令.#003 // #004 //#005 LRESULT CCaiWinMsg::OnCommand(int nID,int nEvent)#006 { #007 // 菜单选项命令响应:#008 switch (nID)#009 {#010 case IDC_CREATEBTN:#011 //显示一个按钮。#012 if (!m_hBtn)#013 {#014 m_hBtn = CreateWindow(_T("BUTTON"),_T("按钮"),#015 WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,#016 50,50,100,32,#017 m_hWnd,(HMENU)IDC_BTN,m_hInstance,NULL);#018 } #019 break;#020 case IDC_BTN: #021 OutputDebugString(_T("按钮按下 "));#022 {#023 static bool bChangeText = true;#024 if (bChangeText)#025 {#026 //设置按钮的文字。#027 SetWindowText(m_hBtn,_T("改变它"));#028 #029 //改变按钮窗口的位置和大小。#030 MoveWindow(m_hBtn,10,10,100,32,TRUE);#031 }#032 else#033 {#034 //设置按钮的文字。#035 SetWindowText(m_hBtn,_T("按钮"));#036 #037 //改变按钮窗口的位置和大小。#038 MoveWindow(m_hBtn,50,50,100,32,TRUE);#039 }#040 #041 //每一次都改变。#042 bChangeText = !bChangeText; #043 }#044 break;#045 default:#046 return CCaiWin::OnCommand(nID,nEvent);#047 }#048 #049 return 1;#050 }2023-07-23 19:42:421
vc MFC 如何绘制图片按钮?
现引入bmp文件ID为IDB_BITMAP 在C*dlg类里添加protected:成员HICON m_hIcon;在OnInitDialog()函数中添加如下代码//C*dlg.cppBOOL CDemoDlg::OnInitDialog(){//添加BS_BITMAP风格 m_ctrlButton.ModifyStyle(0, BS_BITMAP); //m_ctrlButton.MoveWindow(10, 10, 32, 32); //加载位图 HINSTANCE hInstance = AfxFindResourceHandle(MAKEINTRESOURCE(IDB_BITMAP), RT_GROUP_ICON); HBITMAP hBitmap = ::LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP)); //设置按钮位图 m_ctrlButton.SetBitmap(hBitmap); return TURE;}如果想实现按下去变换图片则引入bmp文件ID为IDB_BITMAP,IDB_UP, IDB_DOWN 在C*dlg类里添加protected:成员HICON m_hIcon;在OnInitDialog()函数中添加如下代码//C*dlg.cppBOOL CDemoDlg::OnInitDialog(){ CDialog::OnInitDialog(); …… m_ctrlButton.SubclassDlgItem(IDC_BUTTON, this); //添加BS_OWNERDRAW风格 m_ctrlButton.ModifyStyle(0, BS_OWNERDRAW); //m_ctrlButton.MoveWindow(10, 10, 68, 56); //加载按钮位图 m_ctrlButton.LoadBitmaps(IDB_UP, IDB_DOWN); return TRUE;}2023-07-23 19:42:491
C++ 来回移动窗口命令,请大神帮我给改一下
#include<windows.h>void main(){ HWND hwnd; int i; hwnd=FindWindow(NULL,"计算器"); while(true){ i=0; for(;i<20;i++) { //移动计算器 MoveWindow(hwnd,100+i,100,120,180,1); Sleep(2000); } for(i=19;i>=0;i--) { //移动计算器 MoveWindow(hwnd,100+i,100,120,180,1); Sleep(2000); }}} 你太有才了,怎么windows的API放在这里用啊。2023-07-23 19:43:071
vb 获取窗口句柄后如何移动窗口
Option ExplicitPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As LongDim whwnd As Long " 储存 FindWindow 函数返回的句柄Private Sub Command1_Click() MoveWindow whwnd, 1000, 500, 600, 700, 0 "600移动后宽度,700为高度End SubPrivate Sub Form_Load()Timer1.Enabled = TrueTimer1.Interval = 1000End SubPrivate Sub Timer1_Timer()whwnd = FindWindow(vbNullString, "我的电脑") " 取得进程标识符If whwnd = 0 ThenLabel1.Caption = "未运行"ElseLabel1.Caption = "已运行,窗口句柄为" & Hex(whwnd)Timer1.Enabled = FalseEnd IfEnd Sub2023-07-23 19:43:201
C++ win 编程 改变窗口大小
MoveWindow(……,……,……,……);2023-07-23 19:43:333
C语言中用MoveWindow()能把一个窗口内的按钮移到这个窗口外面吗?
按钮既然属于这个窗口,当按钮的位置不在窗口范围内时,就不会显示出来,所以不能显示在窗口外.2023-07-23 19:43:391
VB 能否控制 office 应用程序窗口的位置和大小
不能2023-07-23 19:44:083
如何让vc程序自动适应屏幕分辨率大小
可以改变自已程序的界面,将每个控件的位置都计算出来. 看下面这个例子,在窗口大小改变时,窗口里的控件也跟着调整位置. void CEmail::OnSize(UINT nType, int cx, int cy) { CFormView::OnSize(nType, cx, cy); // TODO: Add your message handler code here if(nType==SIZE_RESTORED && cx>=522 && cy>=386) { CWnd *pwnd; CRect rect; pwnd=(CWnd *)GetDlgItem(IDC_COMBO_CATALOG); if(pwnd==NULL)return; pwnd->GetWindowRect(&rect); ScreenToClient(&rect); rect.right=cx-15; rect.left=rect.right - 90; pwnd->MoveWindow(&rect,TRUE); pwnd=(CWnd *)GetDlgItem(IDC_LIST); if(pwnd==NULL)return; pwnd->GetWindowRect(&rect); ScreenToClient(&rect); rect.right=cx-10; rect.bottom=rect.top+cy/3+20; pwnd->MoveWindow(&rect,TRUE); ((CListCtrl *)pwnd)->SetColumnWidth(1, rect.Width()-274); pwnd=(CWnd *)GetDlgItem(IDC_RICHEDIT); if(pwnd==NULL)return; rect.top=rect.bottom+5; rect.bottom=cy-10; pwnd->MoveWindow(&rect,TRUE); } }2023-07-23 19:44:171
如何在VC++中用纯代码生成按钮等控件?
//类定义里CButton m_btn ; //类实现if ( m_btn.Create(...) ){ m_btn.MoveWindow(...); m_btn.ShowWindow( SW_SHOW );}2023-07-23 19:44:244
使用MoveWindow()改变窗口大小时遇到问题了。
ShowWindow(SW_SHOWMAXIMIZED);//最大化显示用这句试试2023-07-23 19:44:432
mfc编程 对话框中的listbox和进度条不能实时刷新,求高手指点!
试试AddString后面加下面这一句:m_ListBox.RedrawWindow();2023-07-23 19:44:502
易语言启动窗口位置如何设置为在屏幕的左上角
在属性里设置 启动窗口的左边为1 顶边为12023-07-23 19:44:572
MFC怎么让主窗口随View类改变大小
刚接触MFC不久,对MFC的许多函数和功能还不是很了解。所以,在仿照书本开发一个仿QQ的通讯程序的时候,就碰到了一个怎么样使控件随着窗体变化的问题。好了,废话不多说,直接上主窗体图: 现在,要实现的功能如下: 使控件CLISTBOX类对象窗口(IDC_QQLISTBOX)以及两个CBUTTON类对象(IDC_MAIL)、(IDC_WEB)随着主窗体的变化而自动变化。 具体操作步骤: 1、在主对话框类class CQQDlg : public CDialog中添加对象CRect m_rect,用来记录当前对话框的大小。并在初始化函数OnInitialDialog()中获取该大小GetClientRect (&m_rect);值得注意的是,初始化函数中的这一步并不是必须的,而且如果是在主窗体生成前使用此函数,还可能会报错,故建议不要这个操作。 2、使用Ctrl+W快捷键弹出MFC ClassWizard窗体,选择主窗体ID,并在Message Map选项中选择WM_SIZE,点击确定,成功添加了OnSize()函数。它的作用在于系统会自动检测窗体的变化情况,一旦发生变化,立即自动调用该函数。如下图所示: 3、定义OnSize()函数,代码如下: void CQQDlg::OnSize(UINT nType, int cx, int cy){CDialog::OnSize(nType, cx, cy); / / nType==1不可以省略,否则由最小化恢复为正常状态下的时候会出错 //nType是一个枚举类型,主要是指定所请求的不同的调整大小。这个参数可以是下列值之一:SIZE_MAXIMIZED、SIZE_MINIMIZED 。SIZE_RESTORED , SIZE_MAXHIDE ,SIZE_MAXSHOW 其原型可以在msdn上查看if(nType==1) return; //最小化则什么都不做 CWnd *pWnd; pWnd = GetDlgItem(IDC_QQLIST); //获取控件句柄ChangeSize(pWnd,cx,cy); //调用changesize()函数pWnd = GetDlgItem(IDC_WEB); //获取控件句柄ChangeSize(pWnd,cx,cy);//调用changesize()函数 //ChangeSize(pWnd,cx,cy)是一个自定义的函数,需要在类的protect属性中进行添加声明afx_msg void ChangeSize(CWnd * pWnd, int cx, int cy);pWnd = GetDlgItem(IDC_MAIL); ChangeSize(pWnd,cx,cy);GetClientRect(&m_rect); //将变化后的对话框设置为旧大小}void CQQDlg::ChangeSize(CWnd * pWnd, int cx, int cy){if (pWnd){CRect rect; pWnd->GetWindowRect(&rect); //获取控件变化前的大小ScreenToClient(&rect);//将控件大小转换为在对话框中的区域坐标 rect.left=rect.left*cx/m_rect.Width();//调整控件大小 ,cx/m_rect.Width()为对话框在横向的变化比例rect.right=rect.right*cx/m_rect.Width(); //cx存储的是变化后的宽度,cy存储的是变化后的高度rect.top=rect.top*cy/m_rect.Height(); //m_rect.height()表示的是变化前主窗体的高度rect.bottom=rect.bottom*cy/m_rect.Height();pWnd->MoveWindow(rect);//设置控件大小}} 注意:GetWindowRect()与GetClientRect(),ScreenToClient()与ClientToScreen()之间的区别 1、GetWindowRect() 是获得窗口在屏幕坐标系下的RECT坐标,包括非客户区(标题栏和下面的其它边框)和客户区(矩形区域),从而得到窗口的大小和相对屏幕左上角(0,0)的坐标。 2、GetClientRect() 取得窗口客户区(不包括非客户区)在客户区坐标系下的RECT坐标,可以得到窗口的大小,而不能得到相对屏幕的位置,因为这个矩阵是在客户区坐标系下(相对于窗口客户区的左上角)的 3、ScreenToClient():把屏幕坐标系下的RECT坐标转换为客户区坐标系下的RECT坐标。 4、 ClientToScreen():把客户区下Rect坐标系转化为屏幕坐标系下的坐标 对GetWindowRect取得的矩阵ScreenToClient后,矩阵的大小没有变小,left,top是窗口的左上角的坐标,相对窗口客户区左上角。对GetClientRect取得的矩阵ClientToScreen后,矩阵的大小也没有变大,新得到的矩阵是窗口客户区在屏幕坐标系上的RECT。2023-07-23 19:45:031
VB如何移动一个外部窗体的位置如到右上角,要求代码实现。
Private Sub Form_Load()Me.Move Screen.Width - Me.Width, 0End Sub2023-07-23 19:45:153