views:

51

answers:

1

I have a button that will launch a process that requires UAC elevation. I want to display the Windows UAC shield overlay on the button, how do I do this in wxPython? The application is only going to run on Windows, so I don't need to worry about it not working on other systems.

edit 2: Got it:

BCM_SETSHIELD = 0x0000160C
btn_apply = wx.Button(self, wx.ID_APPLY, "Apply",
                      wx.DefaultPosition, wx.DefaultSize, 0)
response = win32gui.SendMessage(btn_apply.GetHandle(), BCM_SETSHIELD, None, True)

I put true in the wparam, not lparam of SendMessage, this works now. Now I'm just wondering if BCM_SETSHIELD is declared in some library somewhere in pywin32, but I'm fine with declaring the constant myself if I have to.

+1  A: 

I don't know how to send a Windows message in Python, but I assume you do. You need to send BCM_SETSHIELD with true as the parameter. It will be ignored on XP and earlier. Also make sure the button style is set to FlatStyle.System. The numerical value of BCM_SETSHIELD is 0x0000160C.

Kate Gregory
I tried to do:`BCM_SETSHIELD = 0x0000160C``btn_apply = wx.Button(self, wx.ID_APPLY, "Apply", wx.DefaultPosition, wx.DefaultSize, 0)``response = win32gui.SendMessage(btn_apply.GetHandle(), BCM_SETSHIELD, True)`but it still doesn't show an overlay.
Mike H