|
m_ilToolBar.Create(20,20,ILC_COLOR8,4,4);
Tanvon
the brain behind ...
I Blog here
|
|
|
|
|
after creating the tool bar in main class . i.e CMainFrame . add a image list to the tool bar . that imagelist can containe 256 color icons . and we can give three imaage lists for tool bar . 1 for when button is Active . 2 for Wend button is disabled . and 3rd state is grayed. try this. bye
|
|
|
|
|
sorry I am having today some problem posting answers.
1: load your bitmap
HBITMAP hbm = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDR_MAINFRAME),
IMAGE_BITMAP,
0,0, LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS );
CBitmap bm;
bm.Attach(hbm);
2: make a 256 color image list
CImageList m_ilToolBar.Create(20,20,ILC_COLOR8,4,4);
m_ilToolBar.Add(&bm,(CBitmap*)NULL);
3: select that image list in your app toolbar
m_wndToolBar.GetToolBarCtrl().
SetImageList(&m_ilToolBar);
Tanvon
the brain behind ...
I Blog here
|
|
|
|
|
Tanvon (and everyone else), thanks for the help.
I realize now that in using the Create version that takes a mask param, it's defaulting to 16 color. However, the version that accepts the ILC params doesn't include one to set the mask.
If I use ILC_COLOR8 | ILC_MASK, does the first m_ilToolBar.Add() set the bitmap and the second the mask?
|
|
|
|
|
Have you tried creating the image list object manually? See the ILC_XXX flags as well as the MSDN docs for the Create() method.
If you go for true color, and you use 32 bit icons, do use ILC_COLOR32, as it will preserve the alpha channel information. ILC_COLOR24 will strip the alpha channel information, resulting in VERY ugly images.
Another thing: if you use 32 bit icons - DO NOT open them in the IDE icon editor. It will strip away the alpha channel information, rendering the icons ugly. Even if you don't modify and save the icon, the IDE (VS.NET 2k2 and 2k3 - not sure about 2k5) will silently modify your icons.. Took me a while to figure this out.
[edit]I have also noticed that on Windows 2000 and earlier systems, icons and image lists with 256 colors is rendered better than true color image lists. On XP and later, true color looks better. Why this is, I can't really tell. All I've got to back this up are my own subjective opinions - so don't take this statement as scientifically proven. [/edit]
--
Mit viel Oktan und frei von Blei, eine Kraftstoff wie Benziiiiiiin!
|
|
|
|
|
Hey, man.
Thanks for the heads up on this stuff. I'll try the ILC_COLOR32 & see how it does for me.
Turns out it was defaulting to 16 color because I was using the version of Create() that took a mask param. Using the version that takes the ILC flags, I'm assuming I need to or in the ILC_MASK, but I'm not seeing clear doc on how to subsequently set the mask. Any insights would be appreciated.
|
|
|
|
|
Christopher Duncan wrote: I'm assuming I need to or in the ILC_MASK, but I'm not seeing clear doc on how to subsequently set the mask. Any insights would be appreciated.
There are basically two ways to create image lists. One is to use a mask (in some form), and the other is to specify a transparent color. The mask is either explicit (b&w bitmap), or implicit (embedded mask bitmap inside icon and/or alpha transparency). Either way, you will have to specify ILC_MASK.
The transparency color option is simple to use. AFAIK, you don't have to specify ILC_MASK (with MFC you can't I believe). Pixels with this transparent color will be omitted when you draw the image list, giving the transparency effect. When I use this technique, I use a color which is seldom used in the actual image - RGB(0xFF, 0xFF 0) for instance.
So, this is what I'd do if I were to build an image list out of a set of icons:
CImageList lst;
lst.Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 2);
lst.Create(16, 16, ILC_COLOR24 | ILC_MASK, 0, 2);
lst.Add(hIcon1);
lst.Add(hIcon2); With masking bitmaps:
lst.Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 2);
lst.Add(&bmpImage, &bmpMask); And with a transparent pixel and predefined bitmap I'd do this:
lst.Create(MAKEINTRESOURCE(IDB_MYBITMAP), 16, 2, RGB(0xFF, 0xFF, 0));
Of course, ILC_COLOR8 is perfectly valid should you have bitmaps which share the same palette. If your bitmaps have different palettes, the finished image list may look horrible should the bitmaps which you have added to it, have very different palettes.
My rules of thumb are:
- ILC_COLOR24 for all image lists to which I intend to add different bitmaps and use a transparency color
- ILC_COLOR32 for all image lists for which I intend to add 32 bit icons, just to preserve the alpha channel
- ILC_COLORWhatever for static image lists - i.e., image lists which you feed ONE composite bitmap. Such a bitmap will have only one palette, and is therefore not subject to palette freakization.
Basically it boils down to if you want to build the image list at runtime or not. I increase the bit depth for runtime built image lists to guard against ugliness. I am conservative about the bit depth for compile time build image lists, as 24 bits or more for 8 bit images would just be waste of memory.
--
Mit viel Oktan und frei von Blei, eine Kraftstoff wie Benziiiiiiin!
|
|
|
|
|
I'm up and running. Thanks for the help, man!
|
|
|
|
|
You can solve this via creating and filling your own imagelist at first and which you set to the toolbar.
Greetings from Germany
|
|
|
|
|
I'm up and running, just wanted to take a moment to thank all of you who took the time to help out. I do appreciate it.
Have a good week!
|
|
|
|
|
Hi,
Can u plz say how to convert char* variable to char.
I write the code as shown below
struct row{
char name[50];
char sex[5];
};
I am getting text from the edit box and assigning to row.name, I want to insert row.name into the database.
char *CampID=new char[50];
GetDlgItemText (IDC_EDITCAMPAIGNID,CampID,50);
row.name=CampID;
But I am getting error saying that "Can not convert from char* to char[50]"
Thanks in advance.
|
|
|
|
|
tejaswini.g wrote: char *CampID=new char[50];
GetDlgItemText (IDC_EDITCAMPAIGNID,CampID,50);
row.name=CampID;
you need to use strcpy here.
strcpy(row.name,CampID);
|
|
|
|
|
Thank you.
Shall I ask you One more doubt.
I have created a propertysheet with two property pages.
In the first property page i displayed 'employee names ' from the database and displayed in the grid lines.
I select on name and activate another property page.Using querysiblings i got the name in the second property page.
And using that ,employeename' i write a query to get the data from the database and displayed in the controls.
First time it is running fine.
Second time if i select another emplyoee name I am getting the correct results from database but the old data is displayed in the controls.
Can u plz say How can I solve this problem?
Thanks in advance.
|
|
|
|
|
|
BOOL CCampaignDataEntryDlg::OnInitDialog()
{
CPropertyPage::OnInitDialog();
setUpODBC();// establish database connection
long x=QuerySiblings(1,(long)&m_querySibling);
CString* pString=(CString*)x;
pStr=*pString;
AfxMessageBox(pStr); //display employee name say 'tejaswini'
SQLRETURN sr;
SQLHSTMT hstmt;
CString campid;
campid.Format("SELECT empName,empID FROM EMPLOYEEDETAILS WHERE EMPNAME= '%s'",pStr);
SQLCHAR* SQL = (SQLCHAR*)(LPCSTR)campid;
}
BOOL CCampaignDataEntryDlg::OnSetActive()
{
if(m_Status!="") //m_Status is to used to know whether the
//property page is activated or not
OnInitDialog();
return CPropertyPage::OnSetActive();
}
BOOL CCampaignDataEntryDlg::OnKillActive()
{
m_Status="abc";
return CPropertyPage::OnKillActive();
}
|
|
|
|
|
tejaswini.g wrote: BOOL CCampaignDataEntryDlg::OnSetActive()
{
if(m_Status!="") //m_Status is to used to know whether the
//property page is activated or not
OnInitDialog();
return CPropertyPage::OnSetActive();
}
dont call OnInitDialog here. Instead write that code in OnSetActive .
|
|
|
|
|
|
tejaswini.g wrote: long x=QuerySiblings(1,(long)&m_querySibling);
CString* pString=(CString*)x;
pStr=*pString;
QuerySiblings() does not return a value that can be cast to a CString .
If page two wants to know the name that was selected on page one, store that name in the sheet (the common link between pages).
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I would prefer strncpy(...) and set the last char to zero.
Greetings from Germany
|
|
|
|
|
tejaswini.g wrote: saying that "Can not convert from char* to char[50]"
You can also go around with this using CString if you are using MFC
Define the structure as:
struct row{
CString name;
CString sex;
};
// In your code where you are retrieving the string you can write:
char *CampID=new char[50];
GetDlgItemText (IDC_MYEDIT,CampID,50);
row r;
r.name =(CString )CampID;
AfxMessageBox (r.name); // r.name has same string as CampID
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi,
I want to validate a CEdit control in a property page, I use CEdit::OnKillFocus event. when the user switches to another page ane the contents are invalid I need to force the property sheet to return to the page that includes the invalid data, so how can this be done??
plus, is there a special place (OnValidate) to place my code in instead of placing validation code in KillFocus event???
thanx alot
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
You can handle validations in CPropertyPage::OnKillActive .
|
|
|
|
|
you now a faster way to search into a database ?
this is my code :
void CNcontabile::OnChangeName()
{
CString sCod ;
m_city.GetWindowText(sCod);
CDatabase_Mag* pMag = new CDatabase_Mag();
pMag->SetRowsetSize(25);
if (!pMag->Open())
return;
if (pMag->IsOpen())
{
while(!pMag->IsEOF())
if( sCod == pMag->m_mag)
{
m_name.SetWindowText(pMag->m_den);
}
}
pMag->Close();
}
m_name = CEdit;
m_city = CEdit;
-- modified at 5:20 Tuesday 19th September, 2006
Bravoone
|
|
|
|
|
Yes- you're searching in memory, after reading it all. You need to create a SQL query that returns only the data you're looking for.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
can you give me an example ? ( in my code please!)
Bravoone
|
|
|
|
|