Jump to content
Tuts 4 You
malware

win32 how do i create button and sub window

Recommended Posts

malware

Using native win32 how do i create stylish button and sub window and image background as professional application ? to name a few Eset and Comodo av.

 

eset.png

comodo.png

Share this post


Link to post
Share on other sites
fearless

If we take the buttons (on either screenshot as an example) basically, when you look at them and break them down, essentially all they are are colored rectangles with text and an icon.

So with that in mind, what do we need to use from the win32 functions to recreate that look?

  • FillRect - to paint the background of our button
  • DrawText - to draw the actual text on the button
  • DrawIconEx - to draw an icon

So we could create a custom control that replicates that look.

The other option is to override windows own drawing of standard windows controls: buttons, statics, menus etc using a technique called ownerdrawn, or with some common controls (like listview and treeview), customdraw. These are built into the win32 controls to allow programmers to override and do the drawing ourselves, which allows you to decide what colors, fonts and other things will be used.

 

I created a little gitbook about creating custom controls, for assembler, but as it uses win32 it would apply to other languages as well: https://mrfearless.gitbooks.io/creating-controls-in-assembler/

 

Share this post


Link to post
Share on other sites
atom0s

Most of those anti-virus applications use a theme engine of some sort or, with newer instances, they use HTML/CSS/JS to create the UI via a bundler setup using things like Electron. 

For older anti-virus' a lot of them used SciTer: https://sciter.com/

Share this post


Link to post
Share on other sites
fearless

I created a demo in win32 assembler to mock up a similar ui to the comodo firewall

firewallguicompare.png

Demo has a RadASM project

Icons where taken from the lycia.set file in the themes folder of the comodo installation. Lycia.set is an exe with lots of resources in it. Using Resource Hacker I extracted the svg files and converted them to ico files for the demo.

Not everything is a 100% match, close in most cases. Fonts are probably rendered with gdi+ in the framework that comodo uses, and might be slightly different in sizes etc. And I forgot to put in the mobile, share and help icons at the bottom. Plus the shadow effects around the dialog and panels arent the same. I used my ModernUI framework for most of the ui stuff: www.github.com/mrfearless/ModernUI (work in progress still)

Download project from attachment here or dropbox mirror: https://www.dropbox.com/s/z1i1s4oxzjoitlb/t4yfirewall.zip?dl=0

t4yfirewall.zip

  • Like 2

Share this post


Link to post
Share on other sites
malware
17 hours ago, fearless said:

I created a demo in win32 assembler to mock up a similar ui to the comodo firewall

firewallguicompare.png

Demo has a RadASM project

Icons where taken from the lycia.set file in the themes folder of the comodo installation. Lycia.set is an exe with lots of resources in it. Using Resource Hacker I extracted the svg files and converted them to ico files for the demo.

Not everything is a 100% match, close in most cases. Fonts are probably rendered with gdi+ in the framework that comodo uses, and might be slightly different in sizes etc. And I forgot to put in the mobile, share and help icons at the bottom. Plus the shadow effects around the dialog and panels arent the same. I used my ModernUI framework for most of the ui stuff: www.github.com/mrfearless/ModernUI (work in progress still)

Download project from attachment here or dropbox mirror: https://www.dropbox.com/s/z1i1s4oxzjoitlb/t4yfirewall.zip?dl=0

t4yfirewall.zip

How do i develop using C programming language and how do i use the (UI) with C ? How do i use the modern UI framework with C ?

Share this post


Link to post
Share on other sites
fearless

I have created an x86 demo t4yfirewall using a visual studio 2017 project with the ModernUI controls.

Download project from attachment here or dropbox mirror: https://www.dropbox.com/s/7z457p7mz8ex7xy/t4yfirewall_visualstudio.zip?dl=0

I converted some of the ModernUI controls include (.inc) files to c style header (.h) files, namely the ModernUI base library, ModernUI_Button and ModernUI_CaptionBar, and I'll probably get round to doing others at some point.

Have a look through the source code of the project to see how the control's properties are set. The dialog editor contains the Visual Studio IDE's "custom control" controls to use for the ModernUI controls (think of them as placeholders for the ModernUI controls), which has the correct style flags and class name set - these ModernUI controls are created when the dialog is created, as at the start of the project we register the controls classes with MUIButtonRegister and MUICaptionBarRegister. I found the resource/dialog editor in visual studio a bit more basic compared to the RadASM resource/dialog editor, but I was still able to coax into doing what I needed.

t4yfirewall_visualstudio.zip

Share this post


Link to post
Share on other sites
T-rad

nice looking ui. i cannot seem to get the BN_CLICKED message to register though. loaded your solution in visual studio and added IDC_BTN_SETTINGS to the WM_COMMAND with a simple messagebox but no joy. any suggestions.

    case WM_COMMAND:
        {
            int wmId = LOWORD(wParam);
            // Parse the menu selections:
            switch (wmId)
            {
				case IDC_BTN_SETTINGS:
					MessageBox(0, L"It worked", L"", 0);
					break;
            case IDM_EXIT:
                DestroyWindow(hWnd);
                break;
			case IDOK
				:SendMessage(hWnd, WM_CLOSE, 0, 0);
				break;
			default:
                return DefWindowProc(hWnd, message, wParam, lParam);
            }
        }
        break;

 

 

Share this post


Link to post
Share on other sites
fearless

Apologies, there was slight bug with the ModernUI_Button control, which I discovered the other day and fixed and uploaded to the repo, the example comes with the older lib file that still has that issue, hence why the WM_COMMAND wasnt working properly. I've re-uploaded the example with the correct lib files in the ty4firewall folder, and added the test messagebox for settings to verify it is now working.

Additionally, the repository on github for the controls and framework is: https://github.com/mrfearless/ModernUI

and there is an x64 version (https://github.com/mrfearless/ModernUI64), but it usually lags behind the x86 version, as that is where i do most development, testing, fixing before porting over and updating the x64 repo.

t4yfirewall_visualstudio.zip

Edited by fearless
add ref to ModernUI repo (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites
T-rad

working good now. appreciate the x64 link as it does not show in your repositories

Share this post


Link to post
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

×