x
This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
 
Latest Forum Activity

Module to Modify eVB Window Styles

WinCEDev Page Icon Posted 2023-09-10 8:50 PM
#
Avatar image of WinCEDev
Factorite (Senior)

Posts:
79
Location:
Europe
Status:
This module lets you set various styles and other window properties in your eVB applications.

Various helper functions are provided for common actions, or you can use GetStyle/LetStyle and GetExStyle/LetExStyle to easily set or clear additional styles. Check out the readme file included in the repository for all functions.

For example, to add a maximize and minimize button to the form, you can modify Form_Load as follows:
Private Sub Form_Load() FormExtensions_LetMaximizeBox Me, True FormExtensions_LetMinimizeBox Me, True End Sub

Other features include:

  • Make the window resizable.

  • Add an OK button to the window (requires subclassing).

  • Set the tool window style (window will not appear in the taskbar).

  • Make the window always on top.


The example project demonstrates all of these functions.
To get started, download the repository from the link below, and add the FormExtensions.bas module to your project.

Known Issues:

  • Not all styles work properly in the emulator. They do however work properly on the device.

  • Not strictly an issue, but it appears that in Windows CE, the values for WS_MAXIMIZEBOX and WS_MINIMIZEBOX are switched compared to desktop Windows. The constants in the module have been updated to reflect this. If anyone knows more about this or if it was ever documented anywhere by Microsoft, I would love to know!


Links:

GitHub Repo


Edited by WinCEDev 2023-09-10 9:19 PM




(app.png)



(app_minmaxresize.png)



Attachments
----------------
Attachments app.png (1KB - 0 downloads)
Attachments app_minmaxresize.png (1KB - 0 downloads)
 Top of the page
thenzero Page Icon Posted 2023-09-10 11:24 PM
#
Avatar image of thenzero
Subscribers
H/PC Elite

Posts:
749
Location:
United States
Status:
Wow. Neat. Thanks!
 Top of the page
I dunk for bananas Page Icon Posted 2024-03-31 2:23 AM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
708
Location:
Europe
Status:
Could you explain please what subclassing means exactly and how it would be possible to handle an OK button click?
 Top of the page
WinCEDev Page Icon Posted 2024-04-14 10:27 PM
#
Avatar image of WinCEDev
Factorite (Senior)

Posts:
79
Location:
Europe
Status:
Sorry for the late reply.

Subclassing means that you are taking control of a window's message queue (partially or entirely) instead of letting the eVB runtime handle it for you. Win32 uses messages to notify your program that a certain event has taken place (such as the user pressing a key, tapping the screen, etc), these are initially handled by the runtime and then passed onto your program's event handlers (KeyPress, MouseDown, and such).

However, these do not handle anything that is not explicitly covered by the runtime. Since eVB offers no native way to add an OK button, the events generated by it are not being handled by the runtime functions either. The maximize and minimize buttons are different because they are handled directly by Windows.

By subclassing, you can put your own code before the native handler and take action on anything the runtime does not handle. This is done by first retrieving the memory address of the runtime-provided message handler, and then instructing Windows to instead send messages to the memory address of your own function.

Unfortunately, unlike VB6, eVB lacks the AddressOf operator required to accomplish this, because eVB does not compile down to native code. This is why a third-party component written in C++ is needed that provides a native function for Windows and exposes an event to eVB so you can handle messages. I only found one such component in the SCL called VBCEMessage however it is a demo control, and I don't think there's still a way to buy it.

One last thing of note is that when you create a Pocket PC project, you do get an event to handle an OK button click. However I think this is specific to the Pocket PC runtime, but it might be worth testing to see if we can get this to work on H/PC too.

I recommend reading this article by Microsoft if you want to know more about how window messages work, the article is intended for desktop Windows, but the same concepts also apply to Windows CE: About Messages and Message Queues.
 Top of the page
C:Amie Page Icon Posted 2024-04-15 10:30 AM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
18,053
Location:
United Kingdom
Status:
There was also
https://web.archive.org/web/20030219034237/http://www.intelprog.com/products/prod01.html
and
https://web.archive.org/web/20050219044227/http://www.innovativedss.com/default.asp?id=5

The latter had a free x86 emulator download (probably won't work on real hardware, but might be worth a look)
 Top of the page
Jump to forum:
Seconds to generate: 0.109 - Cached queries : 43 - Executed queries : 30