关于把WS_CHILD 窗口 更改为 WS_POPUPWINDOW 窗口遇到的问题。

枫舞的季节 2003-04-08 09:12:22
问题这样:
我在程序中的Dialog 中嵌入一个子窗口,我需要在一定时候让这个子窗口移动,而且这个移动的范围要允许超出父窗口的范围,因此我就想到把这个窗口设置成为 WS_POPUP
类型的窗口,但是我在设置的时候发现 这个窗口 怎么也不能超出 父窗口的范围移动。
但是我发现 DIALOG 类型的 POPUP 窗口是可以移动到父窗口的范围外去的,请各位大虾帮助!!!THANKS .

...全文
224 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
枫舞的季节 2003-06-06
  • 打赏
  • 举报
回复
结贴。
醉马不肖 2003-04-08
  • 打赏
  • 举报
回复
学习
MFC开发过程序所需的ModifyStyle(needDelStyle,needAddStyle,SWP_FRAMECHANGED); Sytel: WS_BORDER Creates a window that has a border. WS_CAPTION Creates a window that has a title bar (implies the WS_BORDER style). Cannot be used with the WS_DLGFRAME style. WS_CHILD Creates a child window. Cannot be used with the WS_POPUP style. WS_CHILDWINDOW Same as the WS_CHILD style. WS_CLIPCHILDREN Excludes the area occupied by child windows when you draw within the parent window. Used when you create the parent window. WS_CLIPSIBLINGS Clips child windows relative to each other; that is, when a particular child window receives a paint message, the WS_CLIPSIBLINGS style clips all other overlapped child windows out of the region of the child window to be updated. (If WS_CLIPSIBLINGS is not given and child windows overlap, when you draw within the client area of a child window, it is possible to draw within the client area of a neighboring child window.) For use with the WS_CHILD style only. WS_DISABLED Creates a window that is initially disabled. WS_DLGFRAME Creates a window with a double border but no title. WS_GROUP Specifies the first control of a group of controls in which the user can move from one control to the next with the arrow keys. All controls defined with the WS_GROUP style FALSE after the first control belong to the same group. The next control with the WS_GROUP style starts the next group (that is, one group ends where the next begins). WS_HSCROLL Creates a window that has a horizontal scroll bar. WS_ICONIC Creates a window that is initially minimized. Same as the WS_MINIMIZE style. WS_MAXIMIZE Creates a window of maximum size. WS_MAXIMIZEBOX Creates a window that has a Maximize button. WS_MINIMIZE Creates a window that is initially minimized. For use with the WS_OVERLAPPED style only. WS_MINIMIZEBOX Creates a window that has a Minimize button. WS_OVERLAPPED Creates an overlapped window. An overlapped window usually has a caption a
Option Compare Database Option Explicit Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" _ (ByVal dwExStyle As Long, _ ByVal lpClassName As String, _ ByVal lpWindowName As String, _ ByVal dwStyle As Long, _ ByVal x As Long, _ ByVal y As Long, _ ByVal nWidth As Long, _ ByVal nHeight As Long, _ ByVal hWndParent As Long, _ ByVal hMenu As Long, _ ByVal hInstance As Long, _ lpParam As Any) As Long Declare Function LoadIcon Lib "user32" Alias "LoadIconA" _ (ByVal hInstance As Long, _ ByVal lpIconName As String) As Long Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" _ (ByVal hInstance As Long, _ ByVal lpCursorName As String) As Long Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As Long Declare Function RegisterClassEx Lib "user32" Alias "RegisterClassExA" _ (pcWndClassEx As WNDCLASSEX) As Integer Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _ ByVal nCmdShow As Long) As Long Declare Function UpdateWindow Lib "user32" (ByVal hwnd As Long) As Long Declare Function SetFocus Lib "user32" (ByVal hwnd As Long) As Long Declare Function PostMessage Lib "user32" Alias "ostMessageA" _ (ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As Long) As Long Declare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" _ (ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As Long) As Long Declare Function GetMessage Lib "user32" Alias "GetMessageA" _ (lpMsg As MSG, _ ByVal hwnd As Long, _ ByVal wMsgFilterMin As Long, _ ByVal wMsgFilterMax As Long) As Long Declare Function TranslateMessage Lib "user32" (lpMsg As MSG) As Long Declare Function DispatchMessage Lib "user32" Alias "DispatchMessageA" (lpMsg As MSG) As Long Declare Sub PostQuitMessage Lib "user32" (ByVal nExitCode As Long) Declare Function BeginPaint Lib "user32" (ByVal hwnd As Long, lpPaint As PAINTSTRUCT) As Long Declare Function EndPaint Lib "user32" (ByVal hwnd As Long, lpPaint As PAINTSTRUCT) As Long Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, _ ByVal lpStr As String, _ ByVal nCount As Long, _ lpRect As RECT, _ ByVal wFormat As Long) As Long Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, _ ByVal crKey As Long, _ ByVal bAlpha As Byte, _ ByVal dwFlags As Long) As Long Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _ (ByVal hwnd As Long, _ ByVal nIndex As Long) As Long Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _ (ByVal hwnd As Long, _ ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Type WNDCLASSEX cbSize As Long style As Long lpfnWndProc As Long cbClsExtra As Long cbWndExtra As Long hInstance As Long hIcon As Long hCursor As Long hbrBackground As Long lpszMenuName As String lpszClassName As String hIconSm As Long End Type Type POINTAPI x As Long y As Long End Type Type MSG hwnd As Long message As Long wParam As Long lParam As Long time As Long pt As POINTAPI End Type Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Type PAINTSTRUCT hdc As Long fErase As Long rcPaint As RECT fRestore As Long fIncUpdate As Long rgbReserved(32) As Byte End Type Public Const WS_VISIBLE As Long = &H10000000 Public Const WS_VSCROLL As Long = &H200000 Public Const WS_TABSTOP As Long = &H10000 Public Const WS_THICKFRAME As Long = &H40000 Public Const WS_MAXIMIZE As Long = &H1000000 Public Const WS_MAXIMIZEBOX As Long = &H10000 Public Const WS_MINIMIZE As Long = &H20000000 Public Const WS_MINIMIZEBOX As Long = &H20000 Public Const WS_SYSMENU As Long = &H80000 Public Const WS_BORDER As Long = &H800000 Public Const WS_CAPTION As Long = &HC00000 Public Const WS_CHILD As Long = &H40000000 Public Const WS_CHILDWINDOW As Long = (WS_CHILD) Public Const WS_CLIPCHILDREN As Long = &H2000000 Public Const WS_CLIPSIBLINGS As Long = &H4000000 Public Const WS_DISABLED As Long = &H8000000 Public Const WS_DLGFRAME As Long = &H400000 Public Const WS_EX_ACCEPTFILES As Long = &H10& Public Const WS_EX_DLGMODALFRAME As Long = &H1& Public Const WS_EX_NOPARENTNOTIFY As Long = &H4& Public Const WS_EX_TOPMOST As Long = &H8& Public Const WS_EX_TRANSPARENT As Long = &H20& Public Const WS_GROUP As Long = &H20000 Public Const WS_HSCROLL As Long = &H100000 Public Const WS_ICONIC As Long = WS_MINIMIZE Public Const WS_OVERLAPPED As Long = &H0& Public Const WS_OVERLAPPEDWINDOW As Long = (WS_OVERLAPPED Or _ WS_CAPTION Or _ WS_SYSMENU Or _ WS_THICKFRAME Or _ WS_MINIMIZEBOX Or _ WS_MAXIMIZEBOX) Public Const WS_POPUP As Long = &H80000000 Public Const WS_POPUPWINDOW As Long = (WS_POPUP Or WS_BORDER Or WS_SYSMENU) Public Const WS_SIZEBOX As Long = WS_THICKFRAME Public Const WS_TILED As Long = WS_OVERLAPPED Public Const WS_TILEDWINDOW As Long = WS_OVERLAPPEDWINDOW Public Const CW_USEDEFAULT As Long = &H80000000 Public Const CS_HREDRAW As Long = &H2 Public Const CS_VREDRAW As Long = &H1 Public Const IDI_APPLICATION As Long = 32512& Public Const IDC_ARROW As Long = 32512& Public Const WHITE_BRUSH As Integer = 0 Public Const BLACK_BRUSH As Integer = 4 Public Const WM_KEYDOWN As Long = &H100 Public Const WM_CLOSE As Long = &H10 Public Const WM_DESTROY As Long = &H2 Public Const WM_PAINT As Long = &HF Public Const SW_SHOWNORMAL As Long = 1 Public Const DT_CENTER As Long = &H1 Public Const DT_SINGLELINE As Long = &H20 Public Const DT_VCENTER As Long = &H4 Public Const WS_EX_PALETTEWINDOW As Long = &H188 Public Const LWA_ALPHA = &H2 Public Const GWL_EXSTYLE = (-20) Public Const WS_EX_LAYERED = &H80000 Dim strMessage As String '------------------------------------------------------------------------------- Public Function displayMessage(mess As String) As Long strMessage = mess Const CLASSNAME = "我的信息提示~" Const TITLE = "透明提示框!" Dim hwnd As Long Dim wc As WNDCLASSEX Dim message As MSG wc.cbSize = Len(wc) wc.style = CS_HREDRAW Or CS_VREDRAW wc.lpfnWndProc = GetFuncPtr(AddressOf WindowProc) wc.cbClsExtra = 0& wc.cbWndExtra = 0& wc.hInstance = Application.hWndAccessApp wc.hIcon = LoadIcon(Application.hWndAccessApp, IDI_APPLICATION) wc.hCursor = LoadCursor(Application.hWndAccessApp, IDC_ARROW) wc.hbrBackground = GetStockObject(WHITE_BRUSH) wc.lpszMenuName = 0& wc.lpszClassName = CLASSNAME wc.hIconSm = LoadIcon(Application.hWndAccessApp, IDI_APPLICATION) RegisterClassEx wc hwnd = CreateWindowEx(WS_EX_PALETTEWINDOW, _ CLASSNAME, _ TITLE, _ WS_OVERLAPPEDWINDOW, _ 300, _ 100, _ 200, _ 300, _ 0&, _ 0&, _ Application.hWndAccessApp, _ 0&) ShowWindow hwnd, SW_SHOWNORMAL UpdateWindow hwnd SetFocus hwnd Do While 0 <> GetMessage(message, 0&, 0&, 0&) TranslateMessage message DispatchMessage message Loop displayMessage = message.wParam End Function '-------------------------------------------------------------------------------- Public Function WindowProc(ByVal hwnd As Long, _ ByVal message As Long, _ ByVal wParam As Long, _ ByVal lParam As Long) As Long Dim ps As PAINTSTRUCT Dim rc As RECT Dim hdc As Long Select Case message Case WM_PAINT hdc = BeginPaint(hwnd, ps) Call GetClientRect(hwnd, rc) Call DrawText(hdc, strMessage, Len(strMessage), rc, DT_SINGLELINE Or _ DT_CENTER Or DT_VCENTER) Call EndPaint(hwnd, ps) Dim Ret As Long Ret = GetWindowLong(hwnd, GWL_EXSTYLE) Ret = Ret Or WS_EX_LAYERED SetWindowLong hwnd, GWL_EXSTYLE, Ret SetLayeredWindowAttributes hwnd, 0, 200, LWA_ALPHA Exit Function Case WM_KEYDOWN Call PostMessage(hwnd, WM_CLOSE, 0, 0) Exit Function Case WM_DESTROY PostQuitMessage 0& Exit Function Case Else WindowProc = DefWindowProc(hwnd, message, wParam, lParam) End Select End Function '-------------------------------------------------------------------------------- Function GetFuncPtr(ByVal lngFnPtr As Long) As Long GetFuncPtr = lngFnPtr End Function 使用方法: 本帖隐藏的内容 Sub text() Call displayMessage("输入需要警示的内容~") End Sub

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧