|
Hello
I am using 256 color icons for my toolbar, however each of the icons has a white (or light grey) background which is ugly. How is it possible to make the icons transparent on any windows theme?
Thanks in advance.
|
|
|
|
|
i did not try this out, but I would start this way:
subclass the bar
overwrite the WM_CTLCOLOR of the bar
and set in the method
{
pDC->SetBkMode( TRANSPARENT );
return m_LeerBrush;
}
where m_LeerBrush=GetStockObject(HOLLOW_BRUSH)
Then use a transparent color for the icon
hope this helps
|
|
|
|
|
Hello
This will not work.
The toolbar internally works with old primitive bitmaps. (it comes from the Windows 3.1 times)
SetBkMode(TRANSPARENT) is useless for painting bitmaps. It is mainly for printing text.
What you have to do is assign an Imagelist to the toolbar.
The imagelist can maintain a primitive transparency using a mask.
With i_ImageList.SetBkColor(..) you can define with which color the "transparent" pixels are filled.
With i_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON1) you can load transparent icons.
With i_Toolbar->GetToolBarCtrl().SetImageList(&i_ImageList) you assign the image list
And as LAST you can load the toolbar tooltips and Command IDs trom the resources
i_Toolbar.LoadToolBar(IDR_TOOLBAR1);
The images stored in the resources will be overridden with your imagelist.
Please note:
This is NOT real transparency with an Alpha channel!
You can NOT draw XP icons or alpha channel bitmaps with various levels of transparency!
And you can NOT draw on a multicolored backgound.
Elmü
|
|
|
|
|
Any suggestions? Still no luck.
if (!myBar.CreateEx(this, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC))
{
TRACE0("Failed to create toolbar\n");
return -1;
}
myBar.LoadToolBar(IDR_TOOLBAR1);
list1.Create(16, 16, ILC_COLOR32 | ILC_MASK, 2, 2);
list1.SetBkColor(RGB(255,0,0));
list1.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
list1.Add(AfxGetApp()->LoadIcon(IDI_ICON2));
myBar.SendMessage(TB_SETIMAGELIST, 0 , LPARAM (list1.m_hImageList));
myBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&myBar);
|
|
|
|
|
Hi, Try the below code. It will work for sure.
if (!m_wndToolBarMaha.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC ) )
{
TRACE0("Failed to create toolbar\n");
return -1;
}
CWinApp* pApp= AfxGetApp();
m_TBarImages.Create(32, 32, ILC_COLOR, 4, 4);
m_TBarImages.SetBkColor( RGB( 192, 192, 192 ) );
m_TBarImages.Add(pApp->LoadIcon(IDI_ICON1));
m_TBarImages.Add(pApp->LoadIcon(IDI_ICON2));
m_TBarImages.Add(pApp->LoadIcon(IDI_ICON3));
m_wndToolBarMaha.GetToolBarCtrl().SetImageList(&m_TBarImages);
m_wndToolBarMaha.LoadToolBar(IDR_MAINFRAME);
m_wndToolBarMaha.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBarMaha);
Mahadev
|
|
|
|
|
At design time, I need to refresh the Property Browser when giving a property a specific value. Does anyone know how I can do this?
Thank you
|
|
|
|
|
Hi.
I want to write a customized ListBox control, (with UNICODE support and other stuff) for use in a Visual Basic 6.0 application.
I start App.Wizard and I select "MFC ActiveXControl Wizard" project.
Then I select 'ListBox' in step 2 where say "Which window class, if any, should this control subclass"?
But when all is finish and I am with the project created I find that I do not get any ListBox function like AddString(),
GetString(), SetItemData(), etc, etc.
I must write all those functions?
Where could I find some information about creating a new Activex Control based on Listbox.
Thank you.
|
|
|
|
|
The class generated by the wizard is derived from COleControl and by subclassing the window to LISTBOX, it is only subclassing the default LISTBOX. That way, I think you can use normal LB_XXXX messages to addstring, getstring, etc. For example, to add a string, the message to send is LB_ADDSTRING.
Jaime
|
|
|
|
|
Ok.
But the handle from what window should I use as first parameter?
I.E:
in a method inside the activex:
<br />
<br />
...<br />
<br />
::SendMessage(???, LB_ADDSTRING, 0, 0);<br />
<br />
...<br />
??? ->handle to the window will receive the message.
Thank you for your support.
Roger
|
|
|
|
|
The handle is the handle of the COleControl derived class, but, since you are in "this" control, take the :: off.... so the call would be:
SendMessage(LB_ADDSTRING, 0, (LPARAM) _T("Testing"));
Note that call has to be made after the control has been created... for example, after the call to COleControl::OnCreate call and on..
Jaime
|
|
|
|
|
Yes that works!.
But now I have a little problem and I dont know why. I want to handle the message OnDrawItem() and OnMeasureItem() and the program flow never pass through these functions. Do you know what is the problem?.
Thank you very much.
Roger.
PS: Sorry about my english.
Demian.
|
|
|
|
|
Yes that works!.
But now I have a little problem and I dont know why. I want to handle the message OnDrawItem() and OnMeasureItem() and the program flow never pass through these functions. Do you know what is the problem?.
Thank you very much.
Roger.
PS: Sorry about my english.
|
|
|
|
|
Have you modified the style to LBS_OWNERDRAWFIXED or LBS_OWNERDRAWVARIABLE before control creation?
You may also think about painting the control in WM_PAINT message.
Jaime
|
|
|
|
|
Hi Everybody,
We are looking for C++ Programmers in India. Its a contract work for one year. Programmers can work from home.
Please contact Sandeep Gandhi @ Sandeep@landmark4u.com
Thanks
|
|
|
|
|
Does anyone here know how I would go about detecting dependencies for an application and/or DLL. I need to be able to do this in my own source code because I am writing an application that requires this information. Since I can not redistribute dependcy walker or dumpbin ( as far as I know ) i need to do this on my own. If any knows a) how to do this or b) where a good resource about this is I would greatly appreciate it.
Joseph Dempsey
joseph_r_dempsey@yahoo.com
|
|
|
|
|
For implicitly loaded DLLs, check out the .idata section of the file. For explicitly loaded DLLs (i.e., LoadLibrary() ), I do not know of a way.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
I have some modeless dialog, where WebBrowser is downloading
some pages.
I need to do this in background, it means, this window won't be
activated unless user click into the dialog, or will select it in task manager.
How to do this ? Sometimes IE after downloading web page will set this dialog as active
Thank you !
rrrado
|
|
|
|
|
i did not test it, but i would start this way.
after
m_Modelessdialog->ShowWindow(SW_SHOW);
i would use
this->SetActiveWindow();
or
this->SetFocus();
or
this->BringWindowToTop();
etc.
to get the focus pack to the parent.
just try
hope it helps
George
|
|
|
|
|
hi,
i want to create only one connection to my db in my app.
im trying to do myConn.Open() in the InitInstance() function in my App but it throws me an exception. what should i do?!
|
|
|
|
|
Avi Laviad wrote:
...but it throws me an exception. what should i do?!
How about telling us what the exception is, or maybe what the code looks like? It's hard to provide anything useful with the little bit of information you've provided.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
well, here is full detail of my code: (i hope)
in my CXXXApp::InitInstance() i did:
<br />
m_pConnection.CreateInstance(__uuidof(Connection));
try<br />
{<br />
m_pConnection->Open<br />
("Provider=Microsoft.Jet.OLEDB.4.0;"<br />
"Data Source=D:\\DATA\\Nwind.mdb", "", "", -1);<br />
<br />
}<br />
catch(_com_error *e)<br />
{<br />
CString Error = e->ErrorMessage();<br />
AfxMessageBox(e->ErrorMessage());<br />
}<br />
catch(...)<br />
{<br />
<br />
}<br />
when i do this code in my View (it's MDI app) everything works fine.
when i do this - im getting into the catch(...).
is it making any sense to ya?
Avi.
|
|
|
|
|
Avi Laviad wrote:
when i do this - im getting into the catch(...).
What message is displayed?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
no message, i don't have anything in the "catch(...)".
how can i know the message?
(sorry for my , i guess, stupied questions, im a newbie)..
Avi.
|
|
|
|
|
My bad. I saw the one catch statement but not the other. I know of no way to ascertain the type/cause of exception at that point.
The last database application I did, the database object belonged to the document (as opposed to the app or the view). The document had methods for opening and closing the database connection.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|