GUIs via DllCall: control zoo

Post your working scripts, libraries and tools
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

GUIs via DllCall: control zoo

21 May 2017, 18:41

This is the second example in GUIs via DllCall.

GUIs via DllCall: MsgBox - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=30688

And is a DllCall version of:

control zoo (AHK v1.1) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=30652

It tries to create a GUI window with every major control type, and implement a bit of functionality for each one. I made a version of this using AHK v1.1's Gui command, this version uses DllCall instead.

In general each control class had exactly one major sticking point, which slowed down releasing this script, which I will write more about below.

Code: [Select all] [Expand] [Download] (GUIs via DllCall control zoo.ahk)GeSHi © Codebox Plus



[THOUS&TH POST]
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: GUIs via DllCall: control zoo

22 May 2017, 15:25

Notes:

General problems:
- awkwardness regarding window styles for controls, also it appears a control may be instructed to have a style, and then when you receive that style, it appears to be off

Control-specific problems:
;Text [Static]
;Edit [Edit]
;UpDown [msctls_updown32]
- UDM_SETBUDDY := 0x469 is used to join a msctls_updown32 control to an Edit control
;Picture [Static]
;Button [Button]
;Checkbox [Button]
- consider BS_CHECKBOX := 0x2 v. BS_AUTOCHECKBOX := 0x3, BS_AUTOCHECKBOX updates the control's state automatically
;Radio [Button]
- consider BS_RADIOBUTTON := 0x4 v. BS_AUTORADIOBUTTON := 0x9, BS_AUTORADIOBUTTON updates control states automatically
- use WS_GROUP := 0x20000 to specify a new group of radio buttons
;DropDownList [ComboBox]
;ComboBox [ComboBox + Edit]
;ListBox [ListBox]
;ListView [SysListView32 + SysHeader32]
- particularly complicated, if anyone has any comments on this (including if there is an alternative to: each new column becomes leftmost column rather than rightmost column, so I had to add them in reverse order)
- LVM_SETEXTENDEDLISTVIEWSTYLE is needed to make extended styles show
- consider if rightmost column fills the remaining space
;TreeView [SysTreeView32]
;Link [SysLink]
- NM_CLICK := -2 (0xFFFFFFFE), signed numbers needed to be handled
- NM_RETURN := -4 (0xFFFFFFFC), signed numbers needed to be handled
;Hotkey [msctls_hotkey32]
;DateTime [SysDateTimePick32]
;MonthCal [SysMonthCal32]
- to set the date required MCM_SETSELRANGE to specify the same date twice
;Slider [msctls_trackbar32]
;Progress [msctls_progress32]
- the SetWindowTheme dll function is required to create a basic one-colour progress bar
;GroupBox [Button]
;Tab [SysTabControl32]
- what is the difference between AHK's 3 different SysTabControl32 implementations
;StatusBar [msctls_statusbar32]
- consider if rightmost column fills the remaining space
;ActiveX (e.g. Internet Explorer Control) [AtlAxWin + Shell Embedding + Shell DocObject View + Internet Explorer_Server]
- Internet Explorer Control: I had to convert it to not use COM.ahk, based on:
IE_Add() or COM_AtlAxCreateContainer() or AtlAxWin() - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/32138-ie-add-or-com-atlaxcreatecontainer-or-atlaxwin/

;[RICHEDIT50W]
;[Scintilla]
- SciLexer.dll must be downloaded
- Scintilla controls use UTF-8 not UTF-16
;[ToolbarWindow32]
- if more than one button has the same idCommand, then only the last button with that idCommand will have a ToolTip
just me
Posts: 4865
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: GUIs via DllCall: control zoo

05 Jun 2017, 09:44

Hi jeeswg,

I still cannot see real progress. It has been clear that you can show a window containing controls using DllCalls only. AHK does the nothing else. The real challenge is the event/message handling not done automatically by the built-in default window\control procedures.

;ListView [SysListView32 + SysHeader32]
- particularly complicated, if anyone has any comments on this (including if there is an alternative to: each new column becomes leftmost column rather than rightmost column, so I had to add them in reverse order)
LVM_INSERTCOLUMN wrote:wParam
Index of the new column.
Remaining with AHK 1.1.25.02 until v2 will become beta.
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: GUIs via DllCall: control zoo

06 Jun 2017, 21:38

Many thanks for that tip just me.

A separate slightly reworked script to create listviews via DllCall:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Some code for getting/setting the order of listview columns:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

arcticir
Posts: 471
Joined: 17 Nov 2013, 11:32

Re: GUIs via DllCall: control zoo

11 Jun 2017, 03:05

Could you add a sample so that the window is completely transparent and its controls are opaque?
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: GUIs via DllCall: control zoo

12 Jun 2017, 01:01

Do you particularly want to use the GUI via DllCall approach, or would you like it with standard AHK GUIs? I've provided some code for the former and a link for the latter.

What particularly do you have in mind? Do you want a floating controls effect? Cheers.

It's been interesting to look up about setting the GUI background colour.

[an example on standard AHK GUIs]
[SOLVED] Gui opacity - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/80720-solved-gui-opacity/#entry513190

c++ - How to set background color of window after I have registered it? - Stack Overflow
https://stackoverflow.com/questions/3463471/how-to-set-background-color-of-window-after-i-have-registered-it

Edit Control Background Color - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/32364-edit-control-background-color/

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

arcticir
Posts: 471
Joined: 17 Nov 2013, 11:32

Re: GUIs via DllCall: control zoo

12 Jun 2017, 02:37

thank you very much.
Sorry, I did not make it clear.
I would like to use DllCall WINAPI to wrap a complete GUI library
Then i found your script

On the "WinSet, TransColor", there is a problem, if the control uses the same color, the control will become transparent. How to avoid this situation?
Is there any other transparent solution?
e.g. use "SetLayeredWindowAttributes"?
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: GUIs via DllCall: control zoo

12 Jun 2017, 08:51

I don't have any other specific knowledge on this problem, you could try starting a new question on Ask For Help and/or search/ask on another website like Stack Overflow.
arcticir
Posts: 471
Joined: 17 Nov 2013, 11:32

Re: GUIs via DllCall: control zoo

13 Jun 2017, 03:14

OK, Thank you. :)
Helgef
Posts: 2480
Joined: 17 Jul 2016, 01:02
Contact:

Re: GUIs via DllCall: control zoo

13 Jun 2017, 09:04

Cool jeeswg.
My eyes happened to fall on, pWndProc := RegisterCallback(vFunc, "F"), you might want to be careful with that F ;)
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: GUIs via DllCall: control zoo

13 Jun 2017, 10:05

Cheers Helgef.
But what could go wrong? Is the problem if I create two window classes with the same vFunc?
RegisterCallback
https://autohotkey.com/docs/commands/RegisterCallback.htm
Helgef
Posts: 2480
Joined: 17 Jul 2016, 01:02
Contact:

Re: GUIs via DllCall: control zoo

13 Jun 2017, 10:18

Not really. I'm gonna be rude and not give you more hints :lol: (because I'm on the phone, hence typing is awkward)
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: GUIs via DllCall: control zoo

16 Jun 2017, 09:59

Hello Helgef, you were saying ...?

I did notice 'fast mode' was mentioned in the AHK documentation, and read that bit multiple times, but was still unsure as to what it actually did. Thanks.
Helgef
Posts: 2480
Joined: 17 Jul 2016, 01:02
Contact:

Re: GUIs via DllCall: control zoo

16 Jun 2017, 10:35

Did you read: threads and RegisterCallback? I will give you a simple example later if you want, please remind me if I forget.

Cheers.
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: GUIs via DllCall: control zoo

16 Jun 2017, 19:59

Thanks for the 2 links, I did read everything again, it's not immediately clear what the problems could be. So a simple example would be most appreciated. Cheers.
Helgef
Posts: 2480
Joined: 17 Jul 2016, 01:02
Contact:

Re: GUIs via DllCall: control zoo

17 Jun 2017, 03:48

Hi jeeswg.
Consider the following (also follow the comments in the code), let's say we set the SendMode setting to Input in the auto-execute section. (the default if SendEvent)
This means that every newly launched thread will have this setting, for example,

Code: [Select all] [Download] GeSHi © Codebox Plus

SendMode, Input ; Will apply to every new thread.
q::
; This is a new thread.
Msgbox, % A_SendMode ; Input
return

Now, let's say one of our threads, eg a hotkey routine, is interrupted by another thread, eg by a timer routine,

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Here you will notice that the SendMode in the hotkey routine is not affected by the SendMode set in the timer routine, that is in most cases the desired behaviour. Now, how does this relate to RegisterCallback, and the Fast option? Let's try the following, here we simulate our hotkey routine being interrupted by a callback, it will happen between the two messageboxes.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


No problems, right? It behaves just as the timer routine interruption, now change the RegisterCallback to dllcall(registercallback("f","f")), you should be able to guess what's going to happen :o
So when is this a problem? Let's say you are using the zoo gui in an application, and you have a timed subroutine running, like this,

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Observe the inconsistency of the DetectHiddenWindows setting as this timer runs, compare what happens when you do and do not interact with your zoo. This type of inconsistency could cause debugging from hell issues. :angel:

There is one more type of inconsitency that can occur, lets say you make a setting in the auto execute section and then assume that this will apply to your MyWndProc function, so you do not set it there. The thing is then, that every time MyWndProc is called, that setting will be whatever the setting was in the thread which MyWndProc interrupted, because you set have the Fast option for the callback, you may have all kinds of zoo-like behaviour in your script. ;)

Cheers.
arcticir
Posts: 471
Joined: 17 Nov 2013, 11:32

Re: GUIs via DllCall: control zoo

07 Jul 2017, 17:46

Can you add an example of a scroll bar? :)
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: GUIs via DllCall: control zoo

07 Jul 2017, 20:13

Here's some code for scrollbars, put it just before the 'WinShow' line:

Btw I haven't really done anything with scrollbars, most controls come with their own scrollbars if needed. What controls are you going to use a scrollbar with? Cheers.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

arcticir
Posts: 471
Joined: 17 Nov 2013, 11:32

Re: GUIs via DllCall: control zoo

07 Jul 2017, 22:55

Thanks.
I need it to scroll through the main window.
I reduced the height of the main window and increased the height of the scroll bar.
But this does not work, I can not scroll the main window, because of what?
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: GUIs via DllCall: control zoo

07 Jul 2017, 23:38

Ah, so you want a scrollbar to scroll the entire window. I haven't done anything like that before. Do you have any links where that is done with AutoHotkey? Do you have a working example of that with the AHK v1 Gui command? Thanks.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 13 guests