Joke Collection Website - Public benefit messages - How to set the background color of Msgbox in VB6.0, urgent!
How to set the background color of Msgbox in VB6.0, urgent!
Get a solid color picture as the background
Option
specific
'*************************************************************
* module: mMsgBoxEx
* Function: Change the font of the dialog box to color and change the background of the picture.
* Call: MsgBoxEx ("Change background dialog!"
, vbOKOnly, "hint",,,
vbCyan)
'*************************************************************
private
Sign CWPSTRUCT
LParam component
long
WParam component
long
Message length
hWnd
be of the same length
End type
Private declaration of sub-replication repository "kernel32" alias
"RtlMoveMemory" (target is arbitrary, source is arbitrary, ByVal length is.
Dragon)
Private declaration function setwindowshookexlib "user32" alias
"SetWindowsHookExA”(ByVal id hook is Long, ByVal lpfn is Long, ByVal hmod is.
Long, ByVal dwThreadId is as long as).
Private declaration function
Call nexthookex lib "user 32" (ByValhhook as long, ByVal nCode As Long, byval.
As long as wParam and lParam)
Private declaration function
Unhook windowshookexlib "user 32" (as long as byvalhhook) is the same length.
private
Declare the function setwindowlonglib "user 32" alias "SetWindowLongA”(ByVal hWnd
Same length, same length as ByVal nIndex, same length as ByVal dwNewLong.
private
Declare the function callwindowproclib "user 32" alias "CallWindowProcA”(ByVal
LpPrevWndFunc is Long, ByVal hWnd is Long, ByVal Msg is Long, ByVal wParam is.
Long,ByVal lParam As Long)
Private declaration function GetClassName Lib
The alias "user32" is "get class name a”(ByVal hWnd is Long, ByVal lpClassName is String,
ByVal nMaxCount is as long as).
Private declaration function SetTextColor
Lib "GDI 32" (as long as Byval HDC and as long as ByVal crColor) is the same length.
private
Declare the function getsyscolorlib "user 32" (as long as byvalnindex) as
long
Private declaration function setbkmodelib "GDI 32" (byval hdcas long,
ByVal nBkMode is as long as).
Private declaration function CreatePatternBrush
Lib "gdi32" (as long as byval hbitmap) is the same length.
Transparent treatment
Common constant transparency
= 1
Private constant WH_CALLWNDPROC = 4
Private constant GWL_WNDPROC =
(-4)
Private constant WM _ CTLCOLORBTN = & ampH 135
Private constant WM_DESTROY =
& deuterium
Private constant WM _ SETTEXT = & ampHC
Private constant WM_CREATE =
& ampH 1
System color constant
Private constant COLOR_BTNFACE =
15
private Const COLOR _ BTN text = 18
Windows message
private
Const WM _ CTLCOLORSTATIC = & ampH 138
Private constant WM_CTLCOLORDLG =
& ampH 136
Private commander
Private lPrevWnd As
long
Private lForecolor is the same length.
Common function SubMsgBox(ByVal
HWnd is Long, ByVal Msg is Long, ByVal wParam is Long, ByVal lParam is Long).
long
Dim text is
line
Select Case
monosodium glutamate
Dialog Color and Label Color Messages
situation
WM_CTLCOLORDLG,
WM_CTLCOLORSTATIC
Debugging. print
wParam & amp
":Wparam "
a set of
Font back transparency
And change the color.
if
Msg = WM_CTLCOLORSTATIC
then
make a telephone call
SetBkMode(wParam,
Transparent)
end
if
make a telephone call
SetTextColor(wParam,
lForecolor)
a set of
background
Pictures.
Submessage box
= CreatePatternBrush(LoadResPicture( 10 1,
0). Handle)
LoadResPicture( 10 1,
0) Processing
It is a picture with the ID of 10 1 in the resource file.
export
function
situation
WM _ destruction
dislodge
MsgBox
subclasses
make a telephone call
SetWindowLong(hWnd,GWL_WNDPROC,lPrevWnd)
end
choose
SubMsgBox = CallWindowProc(lPrevWnd,hWnd,
Msg,wParam,ByVal lParam)
End function
Private function
HookWindow(ByVal nCode as byvalncode, as long as ByVal wParam, as long as ByVal lParam) as
long
Dim tCWP component
CWPSTRUCT
The fuzzy category is
line
This is where you need to hook up.
Messagebox
Copy memory tCWP, ByVal lParam,
Len(tCWP)
If tCWP.message = WM_CREATE
then
sClass =
Space (255)
sClass =
Left(sClass,GetClassName(tCWP.hWnd,ByVal sClass,
255))
If sClass = "#32770 "
then
subclass
Existing Messagebox
create
lPrevWnd
= SetWindowLong(tCWP.hWnd,GWL_WNDPROC,AddressOf
Child message box)
end
if
If ... it will be over.
HookWindow =
CallNextHookEx(lHook,nCode,wParam,ByVal lParam)
End function
public
Function MsgBoxEx(ByVal prompt is a string, and the optional ByVal button is
VbMsgBoxStyle, optional ByVal title in string form, optional ByVal help file in string form.
String, optional ByVal Context As Long, optional ByVal ForeColor As.
ColorConstants =-1).
Dim lReturn As
long
lHook = SetWindowsHookEx(WH _ CALLWNDPROC
HookWindow address,
App。 ThreadID)
set up
default
If Len(Title) = 0, then Title =
App。 title
lForecolor =
GetSysColor(COLOR_BTNTEXT)
If ForeColor & gt then = 0
LForecolor = foreground color
Show the modified
dialog box
LReturn = MsgBox (prompt, button, title,
Help file, context)
make a telephone call
UnhookWindowsHookEx(lHook)
MsgBoxEx = lReturn
end
function
This is a public module. But the picture is fixed in the resource file, so I didn't think of any other way.
If anyone thinks of other solutions, please let me know and we can learn from each other. ^_^
These include:
LoadResPicture( 10 1,
0) Processing
It is a picture with the ID of 10 1 in the resource file.
You can also change it to a picture in the picture box of the form.
For example: form1.picture1.picture.handle.
- Related articles
- How accurate marketing is, how accurate marketing is.
- How to use Baidu Youqianhua Baidu Youqianhua tutorial
- Send a short message to my Unicom number
- How long does it take to reissue the ID card?
- Zhuanghe CDC issued an urgent reminder Zhuanghe CDC issued an urgent reminder message.
- How to inquire about the bank of China Agricultural Bank?
- I'm just a passer-by in your life.
- I hope to know! In order to prevent and control the epidemic, 55 bus lines in Liuzhou were stopped on February 7.
- How to complain about frequent texting in Sanya?
- Health information for customers in dog days.