如何正确调用SetWindowLong函数?(100分)

N

nisky

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button4Click(Sender: TObject);<br>var<br>&nbsp; edittemp:HWND;<br>&nbsp; SetResult,ErrorCode:DWORD;<br>&nbsp; NewCursor:HCursor;<br>begin<br>&nbsp; edittemp:=CreateWindowEx(0,'edit','OldEdit',WS_OVERLAPPED,100,100,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;300,300,0,0,hInstance,nil);<br>&nbsp; if edittemp&lt;&gt;0 then<br>&nbsp; begin<br>&nbsp; &nbsp; ShowWindow(edittemp,SW_SHOWNORMAL);<br>&nbsp; &nbsp; UpdateWindow(edittemp);<br>&nbsp; end<br>&nbsp; else begin<br>&nbsp; &nbsp; Showmessage('创建窗口实例失败!');<br>&nbsp; &nbsp; exit;<br>&nbsp; end;<br>&nbsp; NewCursor:=LoadCursor(0,IDC_WAIT);<br>&nbsp; if Newcursor=0 then<br>&nbsp; &nbsp; &nbsp;Showmessage('Cursor Error!');<br>&nbsp; SetLastError(0);<br>&nbsp; SetResult:=SetWindowLong(edittemp,GCL_HCURSOR,Integer(NewCursor));<br>&nbsp; if SetResult=0 then<br>&nbsp; begin<br>&nbsp; &nbsp; Showmessage('修改属性失败!');<br>&nbsp; &nbsp; ErrorCode:=GetlastError;<br>&nbsp; &nbsp; Showmessage(Inttostr(Loword(ErrorCode)));<br>&nbsp; &nbsp; DestroyWindow(edittemp);<br>&nbsp; &nbsp; exit;<br>&nbsp; end;<br><br>&nbsp; DestroyWindow(edittemp);<br>&nbsp; editEx:=CreateWindowEx(0,'edit','NewEdit',WS_OVERLAPPED,100,100,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;300,300,0,0,hInstance,nil);<br>&nbsp; if editEx&lt;&gt;0 then<br>&nbsp; begin<br>&nbsp; &nbsp; ShowWindow(editEx,SW_SHOWNORMAL);<br>&nbsp; &nbsp; UpdateWindow(editEx);<br>&nbsp; end<br>&nbsp; else begin<br>&nbsp; &nbsp; Showmessage('创建窗口实例失败!');<br>&nbsp; &nbsp; exit;<br>&nbsp; end;<br>end;<br>
 
1。SetWindowLong 第一个参数是 HWND, 你要用 edittemp.Handle 才行<br>2。我没有看到 SetWindowLong 可以跟 GCL_HCURSOR 参数啊<br>3。如果只是改变 cursor 的话,你可以对 edittemp.Cursor 赋值啊<br>
 
edittemp为调用CreateWindow函数的结果,即为该edit的句柄, GCL_HCURSOR这个参数是可以用的,我的程序编译没有错误,只是不能改变窗口类属性
 
我也没有看到GCL_HCURSOR这个参数值的解释.<br>编译没错不代表这个值可以用,nIndex声明为一个整数,只要你用了合法的整数就不会编译错,<br>但有意义的仅下列值:<br><br><br>nIndex <br>Specifies the zero-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra window memory, minus 4; for example, if you specified 12 or more bytes of extra memory, a value of 8 would be an index to the third 32-bit integer. To set any other value, specify one of the following values: Value Action <br>GWL_EXSTYLE Sets a new extended window style. <br>GWL_STYLE Sets a new window style. <br>GWL_WNDPROC Sets a new address for the window procedure. <br>GWL_HINSTANCE Sets a new application instance handle. <br>GWL_ID Sets a new identifier of the window. <br>GWL_USERDATA Sets the 32-bit value associated with the window. Each window has a corresponding 32-bit value intended for use by the application that created the window. <br><br><br>The following values are also available when the hWnd parameter identifies a dialog box: Value Action <br>DWL_DLGPROC Sets the new address of the dialog box procedure. <br>DWL_MSGRESULT Sets the return value of a message processed in the dialog box procedure. <br>DWL_USER Sets new extra information that is private to the application, such as handles or pointers. <br><br><br><br>
 
对不起,我自己把函数写错了,我要调用的是SetClassLong这个函数。
 
多人接受答案了。
 
顶部