Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / newbie: icon and caption

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. newbie: icon and caption
#2473
Posted by: 2003-08-17 05:26:46
I would like to change the default icon of a window, easily, possible?
Giuseppe.
Message2. Re: newbie: icon and caption
#2494
Posted by: 2003-08-21 01:48:10
Easy & possible! :)

win->SetIcon(wxIcon("Iconname",wxBITMAP_TYPE_ICO_RESOURCE));
                                                       (chande this to the format you use)

win->SetTitle("My cool new title");

BTW win is a wxFrame.

upcase
Message3. Re: newbie: icon and caption
#2513
Posted by: 2003-08-22 02:25:05
Hello Upcase, i'm working in windows 98 with dev-c++ 4.9.8.1 and wxWindows 2.4.0.

First try:
// frame constructor
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
       : wxFrame(NULL, -1, title, pos, size, style)
{
    // set the frame icon
    //SetIcon(wxICON(mondrian));
SetIcon(wxIcon("wxProject5.ico",wxBITMAP_TYPE_ICO_RESOURCE));
#if wxUSE_MENUS

Other try:

// and show it (the frames, unlike simple controls, are not shown when
    // created initially)
    frame->Show(TRUE);
    frame->SetIcon(wxIcon("wxProgetto5.ico",wxBITMAP_TYPE_ICO_RESOURCE));

In all cases my icon application change, but the damn windows flag into upper left corner is identical. Possible????

The file .rc :

// THIS FILE WILL BE OVERWRITTEN BY DEV-C++!
// DO NOT EDIT!


A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "wxProject5.ico"




Giuseppe.
Message4. Re: newbie: icon and caption
#2515
Posted by: guidance 2003-08-22 06:39:06
Try:
SetIcon(wxICON(A));
Message5. Re: newbie: icon and caption
#2524
Posted by: 2003-08-23 00:33:24
Hi!
True, "A" is the name of your icon in your resources, so you'd have to use the line
SetIcon(wxICON(A));

or rename your icon.
Have a look at wxIcon in the API. You can use other formats such as
wxBITMAP_TYPE_ICO
wxBITMAP_TYPE_GIF
wxBITMAP_TYPE_XBM
wxBITMAP_TYPE_XPM

Using these formats wx will try to load the icon from a file and not from the resources.
Personally I suggest using XPM whenever you can and avoid embedding stuff to resources, because this makes porting a lot easier.

Btw: wxICON does the following, quoting the API
"This macro loads an icon from either application resources (on the platforms for which they exist, i.e. Windows and OS2) or from an XPM file. It allows to avoid using #ifdefs when creating icons."

upcase
Message6. Re: newbie: icon and caption
#2537
Posted by: 2003-08-23 21:40:27
Hi,
have the same problem like giuseppe with the expection that nothing changes :-/ :




bool mainApp::OnInit()
  {
  mainFrame *frame = new mainFrame(_T("smartEdit"),
                                 wxPoint(50, 50), wxSize(450, 340));
                                
  //frame->SetIcon(wxIcon("smartEdit.ico", wxBITMAP_TYPE_ICO_RESOURCE));
  frame->SetIcon(wxICON(A));
  frame->Show(TRUE);


  return TRUE;
  }




My rc file looks the same like giuseppes (A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "smartEdit.ico")

Am i doing something wrong ?

Message7. Re: newbie: icon and caption
#2539
Posted by: 2003-08-23 21:42:52
thanx to you, Upcase and Guidance, very cool!!! ...is easiest than fox-toolkit library!

Giuseppe.
Message8. Re: newbie: icon and caption
#2542
Posted by: guidance 2003-08-23 22:07:15
A is just the internal name set by Dev-Cpp, the icon is selected at project options dialogue, isn't it?
Message9. Re: newbie: icon and caption
#2543
Posted by: 2003-08-23 22:55:56
Thats true,
but i'm unable to change the frameicon...




mainFrame::mainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
         : wxFrame(NULL, -1, title, pos, size, style)
  {
  SetIcon(wxIcon("smartEdit.ico", wxBITMAP_TYPE_ICO_RESOURCE));




i only getting the standart win32 icon :-(
Message10. Re: newbie: icon and caption
#2545
Posted by: 2003-08-24 01:43:24
Your file.rc content?

---------------------------------------------------------------------------------------
Yet i'm tried to use xpm icons:

#if !defined(__WXMSW__) || wxUSE_XPM_IN_MSW
/* Closed folder */
static char * icon1_xpm[] = {
/* width height ncolors chars_per_pixel */
"16 16 6 1",
/* colors */
"   s None  c None",
".  c #000000",
"+  c #c0c0c0",
"@  c #808080",
"#  c #ffff00",
"$  c #ffffff",
/* pixels */
"                ",
"   @@@@@        ",
"  @#+#+#@       ",
" @#+#+#+#@@@@@@ ",
" @$$$$$$$$$$$$@.",
" @$#+#+#+#+#+#@.",
" @$+#+#+#+#+#+@.",
" @$#+#+#+#+#+#@.",
" @$+#+#+#+#+#+@.",
" @$#+#+#+#+#+#@.",
" @$+#+#+#+#+#+@.",
" @$#+#+#+#+#+#@.",
" @@@@@@@@@@@@@@.",
"  ..............",
"                ",
"                "};

#endif

//..........................................

frame->SetIcon(wxIcon("icon1_xpm",wxBITMAP_TYPE_XPM_RESOURCE));



//output:

../../Dev-Cpp/Templates/wx_main5.cpp C:Dev-CppTemplateswx_main5.cpp
In member function `virtual bool
167 C:Dev-CppTemplateswx_main5.cpp
`wxBITMAP_TYPE_XPM_RESOURCE'
167 C:Dev-CppTemplateswx_main5.cpp
(Each undeclared identifier is
 At top level:
51 C:Dev-CppTemplateswx_main5.cpp
[Warning] `char*icon1_xpm[23]' defined



//the output don't works!!! And to set the icon.xpm in file.rc?
//Other solutions using the portable xpm format?

Giuseppe
Message11. Re: newbie: icon and caption
#2546
Posted by: guidance 2003-08-24 10:00:52
Set your smartEdit.ico at project options dialogue and still use A at your source.
Message12. Re: newbie: icon and caption
#2551
Posted by: 2003-08-24 20:38:38
Thanx,
that worked !
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2024-3-28  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0