Jump to content

Set window style of another program?


 Share

Recommended Posts

Any ideas on how to go about setting the window style of another program?

For example, Say I wanted to set notepad as $WS_POPUP

Any ideas?

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

This demo (using PaulIA's AU3 Library) shows the STYLE and EXSTYLE values. I leave it as an exercise for the idle to bit-out the various settings (hint: where there's a Get, there's usually a Set):

#include <GuiConstants.au3>
#include <A3LHeader.au3>
#include <A3LListView.au3>

$hGUI = GUICreate("ListView Edit Lable", 400, 300)
$ListView = GUICtrlCreateListView("col1|col2|col3", 10, 10, 380, 240)
GUICtrlCreateListViewItem("line1|data1|more1", $ListView)
GUICtrlCreateListViewItem("line2|data2|more2", $ListView)
GUICtrlCreateListViewItem("line3|data3|more3", $ListView)
GUICtrlCreateListViewItem("line4|data4|more4", $ListView)
GUICtrlCreateListViewItem("line5|data5|more5", $ListView)
$Btn_Header = GUICtrlCreateButton("Style", 150, 260, 100, 30)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Btn_Header
            $sMsg = "Style: " & _API_GetWindowLong ($hGUI, $GWL_STYLE)
            $sMsg &= @CRLF & "ExStyle: " & _API_GetWindowLong($hGUI, $GWL_EXSTYLE)
            MsgBox(64, "Results", $sMsg)
    EndSwitch
WEnd

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Not sure what PaulIA uses in AU3Lib, but SetWindowLongPtr should be used instead of SetWindowLong. See here for details.

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

Not sure what PaulIA uses in AU3Lib, but SetWindowLongPtr should be used instead of SetWindowLong. See here for details.

The actual _API_* functions are in A3LWinAPI.au3, and he uses SetWindowLong. It's basically a one-liner DLL call though, so you could rewrite as:

Func _API_SetWindowLongPtr($hWnd, $iIndex, $iValue)
  Local $aResult
  $aResult = DllCall("User32.dll", "int", "SetWindowLongPtr", "hwnd", $hWnd, "int", $iIndex, "int", $iValue)
  Return $aResult[0]
EndFunc

The only impact of the superseded call is for 64bit Windows, so no impact for most of us.

PaulIA updates his library regularly, so I'll bet it get tweaked soon anyway.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Good to know. I run things off a USB, which AU3Lib doesn't like, so I haven't seen any source.

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...