|
You forgot to cast pHint to your derived class.
C_Parameters *pParameters = (C_Parameters*)pHint;
int test = pParameters->hello;
Kelly Herald
Software Developer
|
|
|
|
|
Thanks a milion! I hope I did not start any feud between both of you!
Vaclav
|
|
|
|
|
I want to know the encoding format of .rc file in VS 2005.
It is neither in UTF-8 encoding not unicode?
So what is the encoding format?
|
|
|
|
|
It's ANSI in my environment.
Henry David Thoreau wrote: Beware of all enterprises that require new clothes.
|
|
|
|
|
Hi all,
I have a simple dialog with a combo box control, of the Drop-List type.
class CDlg : public CDialog
{
DECLARE_DYNAMIC(CDlg)
public:
CDlg(CWnd* pParent = NULL);
virtual ~CDlg();
void AddOpc() ;
enum { IDD = IDD_DIALOG1 };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
DECLARE_MESSAGE_MAP()
public:
CComboBox m_cbDropList;
};
void CDlg::AddOpc()
{
CString csOpc ;
csOpc = "1st option" ;
m_cbDropList.AddString("1st option") ;
}
And the line in which a string is added makes the program crash.
Any idea??
|
|
|
|
|
is your combobox correctly constructed at that time ?
|
|
|
|
|
What do you mean?
The constructor is called correctly, and the dialog shown properly. It crashes in that precise line m_cbDropList.AddString("1st option") ; . It happens the same with cbDropList.InsertString(...)
|
|
|
|
|
Where is it called?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
My application is a .dll called from a CAM application. I'm testing the combo box, so this dialog is directly called from the dll.
|
|
|
|
|
Hence maybe the function populating the combobox is called before the dialog is actually loaded.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I don't understand. How can that be possible??
|
|
|
|
|
Creating an instance of a CDialog class doesn't create a dialog window (and its controls). Hence you have a CComboBox variable but not the related control (i.e. window). The dialog window (and its controls) are created during DoModal call.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
oooh
that's new... thanks.
|
|
|
|
|
in the main program:
CDlg Dialog ;
Dialog.AddOpc() ;
Dialog.DoModal() ;
|
|
|
|
|
Yes, as stated, your dialog is not created at the time you try to add:
CDlg Dialog ;
Dialog.AddOpc() ;
Dialog.DoModal() ;
You need to call the AddProc from within the dialog itself - perhaps during the OnInitDialog method.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
If I call AddOpc() in the constructor I get exactly the same error.
|
|
|
|
|
the constrols are not constructed yet in the dialog constructor. you have to do all this in the OnInitDialog() method...
|
|
|
|
|
piul wrote: CDlg Dialog ;
Dialog.AddOpc() ;
Dialog.DoModal() ;
The second line is wrong since the dialog isn't yet created.
Since (due to modal nature of the dialog) you need to add strings before the DoDialog call but you can't add them directly to the combo box that isn't yet alive, hence you should modify AddOpc method to store passed strings inside a string array and use the latter to initilize the combo box inside the OnInitDialog method.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Ok!
How do I include that in OnInitDialog?? Where's that method? Do I have to overload it somehow?
(As you can tell I'm not very experienced in dialog... it's all very confusing..)
|
|
|
|
|
I give you a simple example:
void CDlg::CDlg()
{
m_iItemCount=0;
}
void CDlg::AddOpc(CString szItem)
{
if ( m_iItemCount < 10)
{
m_szItem[m_iItemCount] = szItem;
m_iItemCount;
}
}
BOOL CDlg::OnInitDialog()
{
for (int i=0; i<m_iitemcount; i++)<br="" mode="hold" /> {
m_cbDropList.AddString(m_szItem[i]);
}
return TRUE;
}
Where m_iItemCount is a CDlg int member variable and m_szItem is an array CStrings having 10 elements, also member of CDlg .
(I used a fixed size array to keep things simple).
The calling code will be
CDlg Dialog;
Dialog.AddOpc("foo");
Dialog.AddOpc("piul");
Dialog.DoModal()
To override OnInitDialog , select your CDlg class, go to the properties pane, click the overrides button, and choose <add>OnInitDialog</add> .
Hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Ooops! It works if I call AddOpc() from an event handler of a button, for example
|
|
|
|
|
How to let CPropertyPage look like 3d?
http://cid-fbeb6373d9321a7f.skydrive.live.com/self.aspx/Questions/sheetandpage.rar
I put my source code in the web.
There are two project in the rar file.
First project called "C25 ListProperty" has 3d-look property-page. That is sample of a book about vc++ 6.0 MFC(chinese tradition lang)
Second project called "ShadowTool" has flat-look property-page.
I create "ShadowTool" in vc++ 2005.
The difference between the two projects is that the "ShadowTool" use the sheet is inherited from CPropertySheet.
|
|
|
|
|
akira32 wrote: http://cid-fbeb6373d9321a7f.skydrive.live.com/self.aspx/Questions/sheetandpage.rar
I put my source code in the web.
And you expect us to go there and wade through it all?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I want you to download it and see the picture about 3d and flat-look PropertySheet. Of course, the rar file include the complete source code about two projects.
|
|
|
|
|
Hy everyone again,
Thanks for the ones who responded me earlyer (Hamid, Pallini), but unfortunately that doesn't helped.
I need to get somehow informations about some files stored on my PC (name, size, last modified, etc.).
I am using Visual C++ 2005 and I can't use CFile or other functions that are using other windows dll-s and witch requires Windows only (so MSDN doesn't help ).
That's because my console application must be converted in a dll and be used into an XPCOM component (like Mozilla's ones) and work on any platform windows, linux, mac.
is there any class or function made by someone?
Thanks very much !
|
|
|
|