窗口处理控件技巧大全

【菜科解读】
private sub controlsize(controlname as control, settrue as boolean)dim dwstyle as longdwstyle = getwindowlong(controlname.hwnd, gwl_style)if settrue thendwstyle = dwstyle or ws_thickframeelsedwstyle = dwstyle – ws_thickframeend ifdwstyle = setwindowlong(controlname.hwnd, gwl_style, dwstyle)setwindowpos controlname.hwnd, controlname.parent.hwnd, 0, 0, 0, 0, swp_nozorder or swp_nosize or swp_nomove or swp_drawframeend sub用法:controlsize picture1,true;设置第二个参数为false取消这种设置,下同——————————————————————————–例子二:任何一个控件,我们都可以控制其显示风格为对话框的风格。
private sub controldialog(controlname as control, settrue as boolean)dim dwstyle as longdwstyle = getwindowlong(controlname.hwnd, gwl_style)if settrue thendwstyle = dwstyle or ws_dlgframeelsedwstyle = dwstyle – ws_dlgframeend ifdwstyle = setwindowlong(controlname.hwnd, gwl_style, dwstyle)setwindowpos controlname.hwnd, controlname.parent.hwnd, 0, 0, 0, 0, swp_nozorder or swp_nosize or swp_nomove or swp_drawframeend sub用法:controlsize picture1,true——————————————————————————–例子三:任何一个控件,我们都可以控制其显示风格为模式对话框的风格private sub controlmodal(controlname as control, settrue as boolean)dim dwstyle as longdwstyle = getwindowlong(controlname.hwnd, gwl_style)if settrue thendwstyle = dwstyle or ws_popupelsedwstyle = dwstyle – ws_popupend ifdwstyle = setwindowlong(controlname.hwnd, gwl_style, dwstyle)setwindowpos controlname.hwnd, controlname.parent.hwnd, 0, 0, 0, 0, swp_nozorder or swp_nosize or swp_nomove or swp_drawframeend sub用法:controlmodal picture1,true——————————————————————————–例子四:任何一个控件,我们都可以给它加上标题栏,通过拖动标题栏,可以实现控件的运行时移动。
private sub controlcaption(controlname as control, settrue as boolean) dim dwstyle as longdwstyle = getwindowlong(controlname.hwnd, gwl_style)if settrue thendwstyle = dwstyle or ws_captionelsedwstyle = dwstyle – ws_captionend ifdwstyle = setwindowlong(controlname.hwnd, gwl_style, dwstyle)setwindowpos controlname.hwnd, controlname.parent.hwnd, 0, 0, 0, 0, swp_nozorder or swp_nosize or swp_nomove or swp_drawframeend sub用法:controlcaption picture1,true——————————————————————————–例子五:任何一个控件,我们都可以给它加上controlbox(所谓controlbox,就是窗体的图标+最小化+最大化+关闭按钮)。
private sub controlsysmenu(controlname as control, settrue as boolean)dim dwstyle as longdwstyle = getwindowlong(controlname.hwnd, gwl_style)if settrue thendwstyle = dwstyle or ws_sysmenuelsedwstyle = dwstyle – ws_sysmenuend ifdwstyle = setwindowlong(controlname.hwnd, gwl_style, dwstyle)setwindowpos controlname.hwnd, controlname.parent.hwnd, 0, 0, 0, 0, swp_nozorder or swp_nosize or swp_nomove or swp_drawframeend sub用法:controlcaption picture1,true:controlsysmenu picture1,true 窗口,处理,控件,技巧,大全,一下,例子,中,可能,