|
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
|
|
|
|
|
Are you sure you called CoIninitialize(NULL) before CreateInstance call?
If you didn't call, you need to add that call before the CreateInstance and CoUninitialize() in ExitInstance function.
Jaime
|
|
|
|
|
well thanks you very very much jaime!!!
thank you all for your patient..
Avi
|
|
|
|
|
Some additional comments.
1.- Be sure CoInitialize is only called once in your application, and CoUninitialize is called just before shutting down the application.
2.- There was an easy way you could use to know which error occured. You know that CreateInstance returns an HRESULT. If after the call the pointer was 0x00000000, you can know the error by mean of the HRESULT (0 means no error).
For example, write the line this way:
HRESULT hr = ....CreateInstance(...);
or
TRACE("%x", ....CreateInstance(...));
Then copy the resulting code to the clipboard and finally, run the Error Lookup utility (present in Microsoft Visual Studio Tools menu). The copied error code will appear in Value edit box. Press Look Up button and the corresponding message will appear in Error Message window. For example, for your particular error, hr is 0x800401F0... using Error Lookup, you will get the message "CoInitialize has not been called".
Alternatively you can search that HRESULT code in winerror.h file.
Cheers
Jaime
|
|
|
|
|
wow!!
it's one of the help that i need to make as a Favourite Page.
10x man!
Avi.
|
|
|
|