ghosthsg 发表于 2006-4-29 09:28:00

程序冲突!如何解决???

<P>Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long<BR>Private Const WS_EX_LAYERED = &amp;H80000<BR>Private Const LWA_ALPHA = &amp;H2<BR>Private Const GWL_EXSTYLE = (-20)<BR>Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long<BR>Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long<BR>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<BR>'我们将要调用的那个消息,在MSDN中搜索WM_SYSCOMMAND就可以找到具体说明<BR>Const WM_SYSCOMMAND = &amp;H112<BR>'这个参数指明了我们让系统启动屏幕保护<BR>Const SC_SCREENSAVE = &amp;HF140&amp;<BR>Private Sub Command1_Click()<BR>SendMessage Me.hwnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0<BR>Me.Timer1.Enabled = False<BR>End Sub</P>
<P><BR>Private Sub Form_Load()<BR>Dim rtn As Long<BR>&nbsp;&nbsp; rtn = GetWindowLong(Me.hwnd, GWL_EXSTYLE)&nbsp; '取的窗口原先的样式<BR>&nbsp;&nbsp; rtn = rtn Or WS_EX_LAYERED&nbsp;&nbsp;&nbsp; ' 使窗体添加上新的样式WS_EX_LAYERED<BR>&nbsp;&nbsp; SetWindowLong Me.hwnd, GWL_EXSTYLE, rtn&nbsp;&nbsp; ' 把新的样式赋给窗体<BR>&nbsp;&nbsp; SetLayeredWindowAttributes Me.hwnd, 0, 200, LWA_ALPHA<BR>End Sub<BR></P>
<P>在vb里,这些程序如果在窗体里出现就会和Msgbox冲突,我试了好多次都没有用,版主帮忙解决一下!!!</P>

xinghesnak 发表于 2006-4-30 08:40:00

<P>兄弟,你的代码可真有意思,窗体半透明,还启动屏保。。。。</P>
<P>在我这里和MSGBOX并不冲突,你能抓个错误图片放上来吗?</P>
<P>如果这里解决不了,就去CSDN吧,那里是纯VB编程的,专业性较强。。。。</P>

ghosthsg 发表于 2006-4-30 09:01:00

<P>错误就是说我的“无效的调用过程或参数”!</P>
<P>我也好纳闷的,我只是看到帖子上有就拿来用,谁知道竟然报错!!</P>
<P>还望大侠支持帮助解决!!</P>

xinghesnak 发表于 2006-4-30 10:19:00

<P>知道了,需要在Form上加上time控件和command控件,你添加了吗?</P>

ghosthsg 发表于 2006-4-30 10:49:00

<P>添加了,可还是没有用。。。</P>

xinghesnak 发表于 2006-4-30 11:14:00

<P>你说的那个错误是程序走到哪个语句时报的错啊?</P>

ghosthsg 发表于 2006-4-30 11:29:00

<P>只要遇到Msgbox就报错。。</P>
<P>呵呵</P>
页: [1]
查看完整版本: 程序冲突!如何解决???