|
gajendrakashyap wrote: When I execute the application it gives a runtime error
Where it takes you in the code ?(can you follow callstack).
I dont think, this error related to owner drawn combo box. You must be doing something wrong with other code.
|
|
|
|
|
I'm getting the exception in this call,
dc.DrawText(
lpszText,
strlen(lpszText),
&lpDrawItemStruct->rcItem,
DT_CENTER|DT_SINGLELINE|DT_VCENTER);
I just directly reused the code from "http://msdn2.microsoft.com/en-us/library/y5hb5f9t(VS.80).aspx[^]"
I think you can reproduce the problem with this code.
Regards,
Gajendra
|
|
|
|
|
gajendrakashyap wrote: I think you can reproduce the problem with this code
No, I cant.
Thats why I said, you are doing something wrong.
Can you show how you have created this control, or you have used DDX ?
|
|
|
|
|
Yes I'm using DDX control. I created the ctrl using drag and drop. Then I created the modeless dlg in OnInitDialog()function of Parent wnd as follows.
Modeless_Dlg* ptr_dlg = new Modeless_Dlg();
if(ptr_dlg)
{
ptr_dlg->Create(IDD_DIALOG_MODELESS, this);
ptr_dlg->ShowWindow(TRUE);
ptr_dlg->m_combo.AddString("FIRST");
ptr_dlg->m_combo.AddString("SECOND");
ptr_dlg->m_combo.AddString("THIRD");
}
else
AfxMessageBox("Error creating dlg");
The overridden drawitem method:
void CCustomComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
ASSERT(lpDrawItemStruct->CtlType == ODT_COMBOBOX);
LPCTSTR lpszText = (LPCTSTR) lpDrawItemStruct->itemData;
ASSERT(lpszText != NULL);
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
ASSERT(lpDrawItemStruct->hwndItem = CWnd::GetSafeHwnd());
// Save these value to restore them when done drawing.
COLORREF crOldTextColor = dc.GetTextColor();
COLORREF crOldBkColor = dc.GetBkColor();
// If this item is selected, set the background color
// and the text color to appropriate values. Erase
// the rect by filling it with the background color.
CBrush br(RGB(255, 0, 0));
if ((lpDrawItemStruct->itemAction | ODA_SELECT) &&
(lpDrawItemStruct->itemState & ODS_SELECTED))
{
// Sets current cursor item color and selected item color
dc.SetTextColor(RGB(0, 255, 255));
// has no effect
//dc.SetBkColor(RGB(255, 0, 0));
// sets current cursor item background
dc.FillSolidRect(&lpDrawItemStruct->rcItem, RGB(0, 0, 0));
if ((lpDrawItemStruct->itemState | ODS_SELECTED) | (lpDrawItemStruct->itemAction & ODA_SELECT) )
dc.FrameRect(&lpDrawItemStruct->rcItem, &br);
}
else
{
// Sets list opening color and default combobox item color
dc.SetTextColor(RGB(0, 255, 255));
dc.FillSolidRect(&lpDrawItemStruct->rcItem, RGB(0, 0, 0));
}
// Draw the text.
dc.DrawText(
lpszText,
strlen(lpszText),
&lpDrawItemStruct->rcItem,
DT_CENTER|DT_SINGLELINE|DT_VCENTER);
// Reset the background color and the text color back to their
// original values.
dc.SetTextColor(crOldTextColor);
dc.SetBkColor(crOldBkColor);
dc.Detach();
}
Thats all the code I've added to the generated code.
I hope this helps you to figure out the problem...
Thanks,
Gaj
|
|
|
|
|
You need to set type property to DropDown instead of DropList .
Go to resource, combo box properties -->styles-->Type , set it to DropDown .
|
|
|
|
|
Thanks for that Prasad... I tried the option. There are two problems with this approach:
1. It does not paint the combobox with the colors that i chose.
2. The selected text is not displayed back in the combobox edit area even if I set the index in the function mapped to ON_CBN_SELCHANGE message.
Can you suggest something on that?
Thanks,
Gaj
|
|
|
|
|
Maybe you forgot to set a value for your combobox and I think you get a runtime error see examples of combobox(DrawItem) on codeproject
|
|
|
|
|
I've referred articles from there. The examples work on simple dialogs but not in my kind of scenario.
Can you try to recreate the scenario as I've mentioned and then provide me a soln if possible?
Thanks,
Gajendra
|
|
|
|
|
if you get this error on DrawText maybe problem is of lpszText,are you sure its valid?
|
|
|
|
|
Ya it should be because it gives this problem only when I set the combobox property to Drop List rather than Drop down.
I'm not able to find a way to do it as per my requirements
Regards,
Gaj
|
|
|
|
|
Dear all,
Currently i am working in creating a property sheet inside a dialog and i am also working in creating a property sheet inside a property page.
There is no problem in creating such a sheet and property pages inside a dialog.
But the problem comes in positioning the property sheet tab controls in right side of the dailog and in vertical positions and to add some images in tab control.
I have used this code to set icons in the tab controls.But it is not working.
CImageList m_imageTab;
m_imageTab.Create(16,16,0,3,3);
m_imageTab.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
m_imageTab.Add(AfxGetApp()->LoadIcon(IDI_ICON2));
m_imageTab.Add(AfxGetApp()->LoadIcon(IDI_ICON3));
CTabCtrl *pTab = internal_sheet.GetTabControl();
pTab->SetImageList(&m_imageTab);
TC_ITEM tcItem;
tcItem.mask = TCIF_IMAGE;
for(int i = 0; i < 3; i++ )
{
tcItem.iImage = i;
pTab->SetItem( i, &tcItem );
}
// I used this member function to set the tab control vertical and i aslo tried the differnt combination of styles.but in vain
internal_sheet.GetTabControl()->ModifyStyle(0,TCS_VERTICAL);
Please some body help me to short out this problem.
:->
Manjunath S
GESL
Bangalore
|
|
|
|
|
hello,
i use vc++ 6.0 and i have a project, that has properly worked !!
I don't know what i have done(with the operating system or something else),
but suddenly the project wouldn't link ? i can compile it but then the linker gives me
the following fault:
error LNK2001: Nichtaufgeloestes externes Symbol "__declspec(dllimport) public: __thiscall std::_Winit
To your information: i use standard-library from objectspace(hp). i have set the path in the options of vc. when i don't set "ignore all standard library" in project settings, then
all is ok. but this means, that i use microsoft stl. but i want't objectspace stl !
Check this, too: the same project, with the same compiler, with the same settings, same stl work
really well on my laptop !
Perhaps somebody out there who can give me a tip ?
thanx
eddyroth
|
|
|
|
|
Hi,
I am interested in developing a file transfer library for use with C++ applications. I need information on how the "resume" feature in download managers like DAP, star-downloader etc work. I would be grateful if someone could direct me to the relevant windows APIs or to some existing open-source projects addressing this issue.
SDX-{5A853460-2944-42f8-84B8-2432DE3657EF}
|
|
|
|
|
SDX-{5A853460-2944-42f8-84B8-2432DE3657EF} wrote: or to some existing open-source projects addressing this issue
Have you looked at WGet[^] it's what I use at home for any large downloads.
SDX-{5A853460-2944-42f8-84B8-2432DE3657EF} wrote: could direct me to the relevant windows APIs or to
There are a couple of articles here at CP, Pause & Resume at Protocol level. (You can implement it in any language)[^]
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
Hey, thanks for the help. I will take a look at both. By the way FYI also take a look at "True Downloader" it's an open-source download manager written in VB 6.0!
SDX-{5A853460-2944-42f8-84B8-2432DE3657EF}
|
|
|
|
|
SDX-{5A853460-2944-42f8-84B8-2432DE3657EF} wrote: written in VB 6.0!
I like VB, but that just seems like an application that's steping out of VBs purview. WGet is Open Source, written C++ and is cross platform. Its a command like application that can set it self to run in the back ground which is very cool...
Good luck with True Downloader, hope it works well for you.
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
hi,
i have a dialog box with its Context help property to be true.Wats the use of this property?? can any one expalin in detail about it.
i have created a winhelp file is there any possibility to make use of Context help property to access the winhelp file??
thanx in advance,
zari
|
|
|
|
|
zareee wrote: have a dialog box with its Context help property to be true.Wats the use of this property?? can any one expalin in detail about it.
It add question mark, along with close button on title bar.After that , on clicking any cotrol, it receives WM_HELP message.
|
|
|
|
|
can u give me sample code using WM_HELP message??
zari
|
|
|
|
|
Have a look at this[^] article.
|
|
|
|
|
|
Is it possible to create a single device using CreateDevice() function and share in multiple views?
Thanks & Regards,
Suman
|
|
|
|
|
What does CreateDevice() do?
To share data in multiple views, you can store it in document class.
From view class, you can use GetDocument to get document class's pointer and use it's data.
|
|
|
|
|
Thanks.
It creates a device to represent display adapter.
I will try and let you know tomorrow.
Thanks & Regards,
Suman
|
|
|
|
|
It seems we cannot use the single device returned by CreateDevice() in more than one view. Because Create device takes the HWND handle of the view.
Thanks & Regards,
Suman
|
|
|
|