Author Topic: questions about wxsmith in CB  (Read 8623 times)

Offline gtafan

  • Almost regular
  • **
  • Posts: 126
questions about wxsmith in CB
« on: April 10, 2017, 04:47:55 pm »
After finally I was able to build wxWidgets 3.0.2 I can make GUIs using wxSmith integrated into CodeBlocks. Making a frame project is really not a problem, but I would like to create custom dialogs inside that frame project. Have used wxDev befor and adding such custom dialogs to a frame project was no problem there. Is there a way to do that in CodeBlocks?
« Last Edit: April 13, 2017, 03:06:07 pm by gtafan »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: adding custom dialog to frame wxsmith project
« Reply #1 on: April 10, 2017, 06:55:16 pm »
wxSmith->Add wxDialog?

Offline gtafan

  • Almost regular
  • **
  • Posts: 126
Re: adding custom dialog to frame wxsmith project
« Reply #2 on: April 11, 2017, 05:26:58 pm »
wxSmith->Add wxDialog?
The "?" was a bit iritating. So I have to open the wxSmith menu and select there Add wxDialog, right? Thanks I try.

OK, that was exactly what I was asking, thanks again.
« Last Edit: April 12, 2017, 01:04:45 pm by gtafan »

Offline gtafan

  • Almost regular
  • **
  • Posts: 126
Re: questions about wxsmith in CB
« Reply #3 on: April 13, 2017, 03:10:22 pm »
So have an other question. Have added an icon to my wxFrame and when I start the application in CB everything worcks fine, but when started the compiled exe on an other PC got the error mesage about mising icon. Have used wxDev befor and there this icon was compiled into exe, is there a way to do that in CB to?
« Last Edit: April 13, 2017, 05:00:11 pm by gtafan »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: questions about wxsmith in CB
« Reply #4 on: April 14, 2017, 05:21:55 pm »
this is only partially a codeblocks question, and i only can help you with the non codeblocks part ;)
I think you need a resource file and the resource compiler...
For the resource file:
https://forums.wxwidgets.org/viewtopic.php?t=35976

For the codeblocks part:
I don't know how exactly codeblocks uses the resource compiler and if mingw ships with one... But at a first test you can simply try to add a resource file with the appropriate extension to the project and cross fingers. Maybe it works... if not we have to look into it.
I have no windows machine at the hand so i can't test it...

A other possibility is to use xpm files...

greetings

Offline gtafan

  • Almost regular
  • **
  • Posts: 126
Re: questions about wxsmith in CB
« Reply #5 on: April 18, 2017, 12:40:40 pm »
To be really precise it´s a wxSmith question, but as far I know wxSmith is some kind of CodeBlocks plugin, so the question is in some way related to CodeBlocks.
With resource file you are meaning that .rc file, right? That .rc file contain the icon for exe, and it worcks without big problems, the only thing that can be called problem there, is the fact that the name of the icon must be set manually.
For seting the icon of a frame there is an other way in wxSmith:





and after I have selected the icon some code like that is generated:

Code
wxIcon FrameIcon;
FrameIcon.CopyFromBitmap(wxBitmap(wxImage(_T("C:\\<path>\\myicon.ico"))));
SetIcon(FrameIcon);
<path> stands for the full path, and this is exactly the problem preventing it to worck on any other PC.

The solution from this thred: http://forums.codeblocks.org/index.php/topic,9047.new.html#new doesn´t worck, as I also wrote there.
« Last Edit: April 18, 2017, 12:51:44 pm by gtafan »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: questions about wxsmith in CB
« Reply #6 on: April 19, 2017, 12:10:08 am »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: questions about wxsmith in CB
« Reply #7 on: April 19, 2017, 10:19:04 am »
Quote
nd after I have selected the icon some code like that is generated:

Code: [Select]

wxIcon FrameIcon;
FrameIcon.CopyFromBitmap(wxBitmap(wxImage(_T("C:\\<path>\\myicon.ico"))));
SetIcon(FrameIcon);

<path> stands for the full path, and this is exactly the problem preventing it to work on any other PC.
of course this won't work. But you should also be able to put relative paths there. Something like _T("res\\myicon.ico")
If you use this approach there are some codeblocks pitfalls:
1) If you run your app within codeblocks your app will search in the project folder for the "res" subfolder:
PATH_TO_YOUR_PROJECT_BASE_FOLDER\res\myicon.ico
2) But if you run your app directly without codeblocks it will search in the application base folder:
PATH_TO_YOUR_EXECUTABLE_FILE\res\myicon.ico
so if you run it outside codeblocks but in the folder structure of codeblocks:
PATH_TO_YOUR_PROJECT_BASE_FOLDER\bin\debug\res\myicon.ico
This is because codeblocks has two targets: build and release and if you make the search path for resources (all relative paths of your app) the base path of the project you don't have to copy the resources into two folders. Of course there is a setting to change this...

As i told you above i have no idea how to embed the icon into the exe. But if you post a full build log how stahta01 suggested maybe we can help you.

Offline gtafan

  • Almost regular
  • **
  • Posts: 126
Re: questions about wxsmith in CB
« Reply #8 on: April 19, 2017, 01:32:48 pm »
If you post a full build log, someone might see the cause of your issue!
http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
You are asking for error mesages produced by compiler, right?
If I am using wxSmith to add icon to frame, there is no error mesages, but geting runtime erors on every other PC. The reason for that runtime errors is known, so no need to diskus it, as such solution is useles for me.
when I try your solution from that thread the error mesage looks like that:



Line 30 in that .cpp file looks like this:

Code
Frame->SetIcon(wxIcon(aaaa));

in the .rc file there is a line like this:

Code
aaaa ICON "myicon.ico"

Sorry if I misunderstood you again.

Offline gtafan

  • Almost regular
  • **
  • Posts: 126
Re: questions about wxsmith in CB
« Reply #9 on: April 19, 2017, 01:35:49 pm »
Quote
nd after I have selected the icon some code like that is generated:

Code: [Select]

wxIcon FrameIcon;
FrameIcon.CopyFromBitmap(wxBitmap(wxImage(_T("C:\\<path>\\myicon.ico"))));
SetIcon(FrameIcon);

<path> stands for the full path, and this is exactly the problem preventing it to work on any other PC.
of course this won't work. But you should also be able to put relative paths there. Something like _T("res\\myicon.ico")
If you use this approach there are some codeblocks pitfalls:
1) If you run your app within codeblocks your app will search in the project folder for the "res" subfolder:
PATH_TO_YOUR_PROJECT_BASE_FOLDER\res\myicon.ico
2) But if you run your app directly without codeblocks it will search in the application base folder:
PATH_TO_YOUR_EXECUTABLE_FILE\res\myicon.ico
so if you run it outside codeblocks but in the folder structure of codeblocks:
PATH_TO_YOUR_PROJECT_BASE_FOLDER\bin\debug\res\myicon.ico
This is because codeblocks has two targets: build and release and if you make the search path for resources (all relative paths of your app) the base path of the project you don't have to copy the resources into two folders. Of course there is a setting to change this...

As i told you above i have no idea how to embed the icon into the exe. But if you post a full build log how stahta01 suggested maybe we can help you.
Just wan to make one thing clear, have no problem with embading icon into exe, the problem is only with the icon for the frame.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: questions about wxsmith in CB
« Reply #10 on: April 19, 2017, 04:12:44 pm »
Quote
You are asking for error mesages produced by compiler, right?
yes. BUT you should read the link he posted... Your image is useless. Please follow exactly the steps in the link. And if you have no luck, follow EXACTLY the last step:
Quote
f you have no luck, you can try to ask in the forum, but read first "How do I report a compilation problem on the forums"

Quote
Just wan to make one thing clear, have no problem with embading icon into exe, the problem is only with the icon for the frame.
By embedding i mean to build into the exe, so you don't have to ship a .ico file, but it is packed into the exe

Have you tried the relative paths?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: questions about wxsmith in CB
« Reply #11 on: April 19, 2017, 04:13:09 pm »
If you post a full build log, someone might see the cause of your issue!
http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
You are asking for error mesages produced by compiler, right?
If I am using wxSmith to add icon to frame, there is no error mesages, but geting runtime erors on every other PC. The reason for that runtime errors is known, so no need to diskus it, as such solution is useles for me.
when I try your solution from that thread the error mesage looks like that:



Line 30 in that .cpp file looks like this:

Code
Frame->SetIcon(wxIcon(aaaa));

in the .rc file there is a line like this:

Code
aaaa ICON "myicon.ico"

Sorry if I misunderstood you again.

You need to post the full build log in code tags; NOT an image of the build message.

Anyone, know of a site that translates the CB FAQs to multiple languages?

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline gtafan

  • Almost regular
  • **
  • Posts: 126
Re: questions about wxsmith in CB
« Reply #12 on: April 19, 2017, 04:55:12 pm »
Quote
You are asking for error mesages produced by compiler, right?
yes. BUT you should read the link he posted... Your image is useless. Please follow exactly the steps in the link. And if you have no luck, follow EXACTLY the last step:
Quote
f you have no luck, you can try to ask in the forum, but read first "How do I report a compilation problem on the forums"

Quote
Just wan to make one thing clear, have no problem with embading icon into exe, the problem is only with the icon for the frame.
By embedding i mean to build into the exe, so you don't have to ship a .ico file, but it is packed into the exe

Have you tried the relative paths?
Not really familiar with that build stuff, so this was already a problem in previous discusion with Tim, and even googletranslator is not helpfull in this case.
I haven´t tried your code with relative path, but have just tried to edit the code line to:
Code
FrameIcon.CopyFromBitmap(wxBitmap(wxImage(_T("myicon.ico"))));
The icon is in the prject folder, so it worcked, but with this solution I still need to destribute the icon with the exe and this is something I don´t want to do. wxDev has put the frame icon into the exe to and after looking exactlly at the code produced by wxDev, looks like it is using something similar, or may be exactly the same, to xpm. So looks like I have to generate .xpm file from the icon and than include somehow that .xpm file.
Also I read in the documentation something about windows handels, no idea if this could be a solution, as im worcking only on Windows and this is the only target OS.
« Last Edit: April 19, 2017, 05:03:21 pm by gtafan »

Offline gtafan

  • Almost regular
  • **
  • Posts: 126
Re: questions about wxsmith in CB
« Reply #13 on: April 19, 2017, 05:25:46 pm »
If you post a full build log, someone might see the cause of your issue!
http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
You are asking for error mesages produced by compiler, right?
If I am using wxSmith to add icon to frame, there is no error mesages, but geting runtime erors on every other PC. The reason for that runtime errors is known, so no need to diskus it, as such solution is useles for me.
when I try your solution from that thread the error mesage looks like that:



Line 30 in that .cpp file looks like this:

Code
Frame->SetIcon(wxIcon(aaaa));

in the .rc file there is a line like this:

Code
aaaa ICON "myicon.ico"

Sorry if I misunderstood you again.

You need to post the full build log in code tags; NOT an image of the build message.

Anyone, know of a site that translates the CB FAQs to multiple languages?

Tim S.
I read the link you posted here, but like I said I am not familiar with all that comandline stuff, so it a bit dificult to understand even after translating into my own language. I can compile a .c/.cpp file with g++ but that all my knowledge about comandline, everithing going over that is not compatible with my skills. I was really not joking when saing, that it took me 1,5 month to build wxWidgets.
The image, I posted is everithing I can see after the compilation is finished, no meter succesfull or not. During the compilation, I can see all that comands, mentioned in that FAQ, but they are away after compiler has finished.
Also for me personally the error mesage make sence, as "aaaa" wasn´t really declared, exept in the .rc file, but that file seems not to be conected to the sources.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: questions about wxsmith in CB
« Reply #14 on: April 19, 2017, 05:40:19 pm »
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F


Quote
Also for me personally the error mesage make sence, as "aaaa" wasn´t really declared, exept in the .rc file, but that file seems not to be conected to the sources.
yes... the compiler needs to know where to find the resource file, but we don't know where the compiler searches. This is all displayed in the compiler command line and the command line is posted in  the "build log" tab and not in the "build message" tab. You posted the later and this has no usefull information for us.

We told you 100 times to read ALL the faq... Sometimes you simply have to follow ALL instructions and don't complain, or think this is not related to you...