wxSmith wxDialog problems when program is run

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
User avatar
Asimov
Knows some wx things
Knows some wx things
Posts: 49
Joined: Tue Nov 17, 2020 6:43 pm

wxSmith wxDialog problems when program is run

Post by Asimov » Sat Nov 21, 2020 2:42 pm

Hi,

I am making a modal dialog which is like a virtual keyboard, so that I can get key combinations.
So this is the first time I have used wxSmith. Apart from the annoying problem of not being able to select multiple objects, or no copy and paste,I am trying to fight through this.

The problem is that in the interface designer it doesn't look too bad, not perfect, but not too bad.
However when I run the program it look awful. It looks like some buttons are indented, and others not.
I am not using any panels or resizers. I initially had a panel behind,but I removed it because it was hard to keep moving my buttons around.
Have to say I am not a fan of wxSmith.

I wonder if anyone can help me with this problem. Perhaps you have done a similar thing?

These are toggle buttons, so they can either be on or off.
Also I will be wanting to loop through all the buttons and read each state of each button. I don't know how to do that yet.

My prime concern is to make it look good. Can anyone tell me why it looks so bad when I run my program?
Attachments
interface2.jpg
This is what it looks like after running my program. It looks like crap
interface2.jpg (18.32 KiB) Viewed 288 times
interface1.jpg
This is in the designer. Even though it is not perfect, it is close to what I want

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2660
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxSmith wxDialog problems when program is run

Post by PB » Sat Nov 21, 2020 3:50 pm

If the screenshot was made on Windows, it seems that your application does not have its application manifest, claiming support for v6 of the Common Controls. Hence, the controls in your application are not themed and look like those from Windows 9x.

If your application project includes wx.rc (and wxUSE_NO_MANIFEST is not #defined as 0), the manifest should be there...
See also e.g. here
viewtopic.php?f=23&t=47676&p=201680&hil ... st#p201682

BTW, seeing as the buttons are oddly aligned even in wxSmith: are you using sizers or just trying to put the controls by hand?

User avatar
Asimov
Knows some wx things
Knows some wx things
Posts: 49
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sat Nov 21, 2020 4:28 pm

Yes it was made on windows.

I am putting them in by hand as i don't need it resizing.
I did try sizers, but the problem is that they kept spacing my buttons apart.
Then I thought about using the gridsizer, but that makes all my buttons in a grid, and because I am trying to make a keyboard, the buttons should be slightly out of line on some lines.

On my main interface I have used sizers, for the most part they are working. There is a small issue, I have yet to work out though.

Bear in mind I have only been using wxWidgets for a week now, so I am very new.
I built my main interface in wxFormbuilder, but I was trying out wxSmith for this one.

PS. I had a look at the other post and I haven't a resource file. Under resources I have got AddShortcut.wxs. I think it isn't there because I started with a blank project, and didn't use the wxWidgets project template. Just don't know how to create it

regards
Asimov

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2660
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxSmith wxDialog problems when program is run

Post by PB » Sat Nov 21, 2020 4:48 pm

Asimov wrote:
Sat Nov 21, 2020 4:28 pm
PS. I had a look at the other post and I haven't a resource file. Just don't know how to create it
Well, Windows resource file source file it is just a text file. You will need one to at least make your program and window have an icon. Just add what is in the screenshot in the thread I linked (and make sure you have that icon, you can use a placeholder one for starters).

User avatar
Asimov
Knows some wx things
Knows some wx things
Posts: 49
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sat Nov 21, 2020 5:36 pm

Had a breakthrough,but I am still stuck.

Right as I said when I set this up I opened a blank project and set up all the includes and stuff,and got it working.
So what I did I open a new project and used the wizard. this created the resource.rc and I copied it to my project and added the file.

This file has
aaaa ICON "wx/msw/std.ico"
#include "wx/msw/wx.rc"

The problem is that I am getting an error now
fatal error: wx/msw/wx.rc: No such file or diectory.

So I went to my C drive where wxWidgets is installed in Program Files (x86)/wxWidgets/include/wx
and the files are there.

I don't understand it. Everything else is working apart from this, and in my build options I ahve the include folder under Search directories, or wxWidgets wouldn't have worked at all, so I am a little stuck. The icon file is also there too

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2660
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxSmith wxDialog problems when program is run

Post by PB » Sat Nov 21, 2020 5:46 pm

You need to set two resource compiler search directories.

1. For all build targets

Code: Select all

$(#wx)\include
2. Build-target specific (needed for the CPU specific manifest), e.g. like this for dynamic debug build

Code: Select all

$(#wx)\lib\gcc_dll\mswud

User avatar
Asimov
Knows some wx things
Knows some wx things
Posts: 49
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sat Nov 21, 2020 6:31 pm

Hi PB,

Well obviously I had all the other directories setup, or codeblocks wouldn't have compiled at all. I didn't have anythingin the Resource compiler, so I added them too. In my compiler I had the full path rather than the wx shorthand notation, which is setup in my global compiler.
I am attaching the pictures in case you can see anything wrong. Even though I have added those include directories it is still not finding the files.
Attachments
codeSettings.jpg

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2660
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxSmith wxDialog problems when program is run

Post by PB » Sat Nov 21, 2020 6:45 pm

I can't see anything wrong there.

Which compiler are you using: resource compiler (windres) bundled with GCC 10 reports the same issue but only when "--use-temp-file" parameter is used which Code::Blocks does not.

Please paste the whole build log, should look something like this (with the highlighted line being the most important)
-------------- Build: Debug in CBTest10 (compiler: msys2-mingw-w64-i686)---------------

g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -ID:\Dev\Desktop\!Lib\wxWidgets-GIT\include -ID:\Dev\Desktop\!Lib\wxWidgets-GIT\lib\gcc_dll\mswud -c D:\Dev\Desktop\CBTest10\CBTest10App.cpp -o obj\Debug\CBTest10App.o
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -ID:\Dev\Desktop\!Lib\wxWidgets-GIT\include -ID:\Dev\Desktop\!Lib\wxWidgets-GIT\lib\gcc_dll\mswud -c D:\Dev\Desktop\CBTest10\CBTest10Main.cpp -o obj\Debug\CBTest10Main.o
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -ID:\Dev\Desktop\!Lib\wxWidgets-GIT\include -ID:\Dev\Desktop\!Lib\wxWidgets-GIT\lib\gcc_dll\mswud -c D:\Dev\Desktop\CBTest10\GUIFrame.cpp -o obj\Debug\GUIFrame.o
windres.exe -ID:\Dev\Desktop\!Lib\wxWidgets-GIT\include -ID:\Dev\Desktop\!Lib\wxWidgets-GIT\lib\gcc_dll\mswud -J rc -O coff -i D:\Dev\Desktop\CBTest10\resource.rc -o obj\Debug\resource.res
g++.exe -LD:\Dev\Desktop\!Lib\wxWidgets-GIT\lib\gcc_dll -o bin\Debug\CBTest10.exe obj\Debug\CBTest10App.o obj\Debug\CBTest10Main.o obj\Debug\GUIFrame.o obj\Debug\resource.res -mthreads -lwxmsw31ud_core -lwxbase31ud -mwindows
Output file is bin\Debug\CBTest10.exe with size 983.83 KB
my $(#wx) is D:\Dev\Desktop\!Lib\wxWidgets-GIT

User avatar
Asimov
Knows some wx things
Knows some wx things
Posts: 49
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sat Nov 21, 2020 6:53 pm

Hi I was just about to post the build log when I saw your message.
I notice for some reason it looks like in the log that it is looking in my project folder for the wx / msw / wx.rc file, even though from my previous post I have the correct include directories set up. I am using the GNU GCC compiler Mingw. I am also on Windows 10. PS just realised it is looing in my project folder because that is where the resource.rc file is doh
Attachments
resourcelog.jpg
resourcelog.jpg (79.04 KiB) Viewed 243 times
Last edited by Asimov on Sat Nov 21, 2020 6:56 pm, edited 1 time in total.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2660
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxSmith wxDialog problems when program is run

Post by PB » Sat Nov 21, 2020 6:56 pm

From the first two parameters of windres it is clear that your include folder is incorrect. Most likely your $(#wx) is invalid.

BTW, please post build logs, not screenshots.

User avatar
Asimov
Knows some wx things
Knows some wx things
Posts: 49
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sat Nov 21, 2020 7:07 pm

Well as a test I removed the include from the Resource Compiler. $(#wx)\lib\gcc_dll\mswud
I know it should be there, but I thought i would remove it to see if the windress error went, and it did,but now it seems to be looking fora file called resource.res, which isn't there of course. Gonna put it back now and try some other stuff. This is so annoying.
-------------- Build: Debug in Hotkey (compiler: GNU GCC Compiler)---------------

windres.exe -I(invalid)\include -J rc -O coff -i D:\DOCUME~1\C__~1\Shortcut\resource.rc -o obj\Debug\resource.res
i686-w64-mingw32-g++.exe -L"C:\Program Files (x86)\wxWidgets\lib\gcc_dll" -o bin\Debug\Hotkey.exe obj\Debug\AddShortcut.o obj\Debug\Main.o obj\Debug\sqlite3\sqlite3.o obj\Debug\src\convert.o obj\Debug\src\database.o obj\Debug\resource.res -lwxmsw31ud_core -lwxbase31ud
D:\DOCUME~1\C__~1\Shortcut\resource.rc:3:10: fatal error: wx/msw/wx.rc: No such file or directory
#include "wx/msw/wx.rc"
^~~~~~~~~~~~~~
compilation terminated.
windres.exe: can't open icon file `wx/msw/std.ico': No such file or directory
windres.exe: preprocessing failed.
Process terminated with status 1 (0 minute(s), 0 second(s))
3 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Last edited by Asimov on Sat Nov 21, 2020 7:12 pm, edited 1 time in total.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2660
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxSmith wxDialog problems when program is run

Post by PB » Sat Nov 21, 2020 7:11 pm

Sorry but that cannot work, if your include folders are wrong, windres cannot fidn msw.rc. You need to set the include files for the resource compiler the same way you did for the C++ compiler.

And obviously, resource.res is the name of the output file (compiled resource file to be linked into the executable) and it is correct.

User avatar
Asimov
Knows some wx things
Knows some wx things
Posts: 49
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sat Nov 21, 2020 7:41 pm

Hi PB,

I think I have solved it. It was something you showed me. You didn't have your xWidget folder on your C: drive,but I did.

So I copied my wxWidgets folder from Program Files(x86) to my H: drive, and it compiled
So in my main settings Resource Compiler I now have this H:\wxWidgets\include

Anyway it compiled and it is looking more modern now.
So it seems the compiler settings are quite happy to point to the C: drive,but the Resource compiler does not like the space in Program Files.
This is really stupid, but that must be the reason.

So now I am going to keep it on my H drive, and change my compiler settings and every to go to the H: drive.
The fact that the Compiler settings are ok with loading from Program Files, but the Resource Compiler can't, looks like a bug in Codeblocks to me.
Thanks for the help.
Attachments
interface3.jpg
Newly compiled
interface3.jpg (17.07 KiB) Viewed 225 times

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2660
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxSmith wxDialog problems when program is run

Post by PB » Sat Nov 21, 2020 7:43 pm

The official recommendation is to not install wxWidgets in path with spaces.

User avatar
Asimov
Knows some wx things
Knows some wx things
Posts: 49
Joined: Tue Nov 17, 2020 6:43 pm

Re: wxSmith wxDialog problems when program is run

Post by Asimov » Sun Nov 22, 2020 12:14 pm

Hi PB,

Well I followed a tutorial online, and it automatically compiled it to Program Files on the C: drive. Normally I don't install stuff there on purpose. So I have now moved the folder and changed all my references to work from the new location.

I have painstakingly put all the keys in. wxSmith needs an update. Not being able to multi select items is a pain.
I did my main form with wxFormBuilder, because it seemed easier, but thought it might be beneficial to learn wxSmith too.

Now all I gotta work out is how to loop through all the buttons and read their states when I click the ok button, which I haven't put in yet.
I have given them all a variable name and an id eg ID_TOG_J for instance. So my thinking is that there may be the a way to loop though and read all states of anything marked ID_TOG.
Attachments
fullKeyboard.jpg
fullKeyboard.jpg (43.45 KiB) Viewed 151 times

Post Reply