设置用SetWindowLong,具体参数含义帮助里面很详细。

解决方案 »

  1.   

    取得窗口的风格信息!比如是否有Caption,边框等等.
    随手写的,也不一定正确:
    SetWindowLong(handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) and not WS_Caption)....
      

  2.   

    该函数获得有关指定窗口的信息,函数也获得在额外窗口内存中指定偏移地址的32位长整型值。
    LONG GetWindowLong(HWND hWnd,int nindex);
    hwnd:窗口句柄及间接给出的窗口所属的窗口类。
    NIndex:指定要获得值的大于等于0的值的偏移量。具体取值含义请参看Delphi帮助。
    返回值:如果函数成功,返回值是所需的32位值,如果失败,返回值是0
      

  3.   

    he GetWindowLong function retrieves information about the specified window. The function also retrieves the 32-bit (long) value at the specified offset into the extra window memory of a window. LONG GetWindowLong(    HWND hWnd, // handle of window
        int nIndex  // offset of value to retrieve
       );
     ParametershWndIdentifies the window and, indirectly, the class to which the window belongs. nIndexSpecifies the zero-based offset to the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window memory, minus four; 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 retrieve any other value, specify one of the following values: Value Action
    GWL_EXSTYLE Retrieves the extended window styles.
    GWL_STYLE Retrieves the window styles.
    GWL_WNDPROC Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure.
    GWL_HINSTANCE Retrieves the handle of the application instance.
    GWL_HWNDPARENT Retrieves the handle of the parent window, if any.
    GWL_ID Retrieves the identifier of the window.
    GWL_USERDATA Retrieves 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.
     The following values are also available when the hWnd parameter identifies a dialog box: Value Action
    DWL_DLGPROC Retrieves the address of the dialog box procedure, or a handle representing the address of the dialog box procedure. You must use the CallWindowProc function to call the dialog box procedure.
    DWL_MSGRESULT Retrieves the return value of a message processed in the dialog box procedure.
    DWL_USER Retrieves extra information private to the application, such as handles or pointers.
     Return ValuesIf the function succeeds, the return value is the requested 32-bit value.
    If the function fails, the return value is zero. To get extended error information, call GetLastError. ResReserve extra window memory by specifying a nonzero value in the cbWndExtra member of the 
    WNDCLASS structure used with the RegisterClass function. 
      

  4.   

    Unit
    Windows.PasGetWindowLong(
    hWnd: HWND; {a handle to a window}
    nIndex: Integer {the offset of the value to retrieve}
    ): Longint; {returns a 32 bit value}Description
    This function returns the 32 bit value at the specified offset into the extra window memory for the specified window. This extra memory is reserved by specifying a value in the WndExtra member of the TWndClass structure used when the RegisterClass function is called. In addition, this function can return information about the window by using one of the values for the Index parameter.Parameters
    hWnd: A handle to the window with the extra window memory to be accessed.nIndex: Specifies the zero based byte offset for the value to be retrieved. This can be a value between zero and the number of bytes of extra window memory minus four (i.e. if 16 bytes of extra window memory are allocated, a value of 8 would index into the 3rd 32 bit value).Return Value
    If this function succeeds, it returns the 32 bit value at the specified index into the window memory area; otherwise it returns zero. To get extended error information, call the GetLastError function.举个例子:
    procedure TForm1.CheckBox1Click(Sender: TObject);
    var
       WindowStyle: Longint;   // holds the window style
    begin
       {get the current styles used by this window}
       WindowStyle:=GetWindowLong(Form1.Handle, GWL_STYLE);   {toggle the WS_CAPTION style}
       if (CheckBox1.Checked) then
          WindowStyle:=WindowStyle OR WS_CAPTION
       else
          WindowStyle:=WindowStyle AND NOT WS_CAPTION;   {toggle the WS_BORDER style}
       if (CheckBox2.Checked) then
          WindowStyle:=WindowStyle OR WS_BORDER
       else
          WindowStyle:=WindowStyle AND NOT WS_BORDER;   {toggle the WS_SYSMENU style}
       if (CheckBox3.Checked) then
          WindowStyle:=WindowStyle OR WS_SYSMENU
       else
          WindowStyle:=WindowStyle AND NOT WS_SYSMENU;   {toggle the WS_MAXIMIZEBOX style}   if (CheckBox4.Checked) then
          WindowStyle:=WindowStyle OR WS_MAXIMIZEBOX
       else
          WindowStyle:=WindowStyle AND NOT WS_MAXIMIZEBOX;   {toggle the WS_MINIMIZEBOX style}
       if (CheckBox5.Checked) then
          WindowStyle:=WindowStyle OR WS_MINIMIZEBOX
       else
          WindowStyle:=WindowStyle AND NOT WS_MINIMIZEBOX;
       {make the window use the new styles}
       SetWindowLong(Form1.Handle, GWL_STYLE, WindowStyle);   {this little trick forces the entire window to redraw,
        including non-client areas}
       SetWindowPos(Handle, 0, 0, 0, 0, 0, SWP_DRAWFRAME or SWP_NOACTIVATE or
                    SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER);   {display the current styles used by this window}
       Label1.Caption:='Current Style: '+IntToStr(WindowStyle);
    end;procedure TForm1.FormCreate(Sender: TObject);
    var
       WindowStyle: Longint;   // holds the window style informationbegin
       {get the current styles used by this window}
       WindowStyle:=GetWindowLong(Form1.Handle, GWL_STYLE);   {initialize the check boxes according to the styles that are present}
       if (WindowStyle AND WS_CAPTION)>0 then CheckBox1.Checked:=TRUE;
       if (WindowStyle AND WS_BORDER)>0 then CheckBox2.Checked:=TRUE;
       if (WindowStyle AND WS_SYSMENU)>0 then CheckBox3.Checked:=TRUE;
       if (WindowStyle AND WS_MAXIMIZEBOX)>0 then CheckBox4.Checked:=TRUE;   if (WindowStyle AND WS_MINIMIZEBOX)>0 then CheckBox5.Checked:=TRUE;   {hook up the OnClick events for the checkboxes. this step is necessary
        because the OnClick event is automatically fired when the Checked
        property is accessed.}
       CheckBox1.OnClick:=CheckBox1Click;
       CheckBox2.OnClick:=CheckBox1Click;
       CheckBox3.OnClick:=CheckBox1Click;
       CheckBox4.OnClick:=CheckBox1Click;
       CheckBox5.OnClick:=CheckBox1Click;
    end;