|
|
Hi,
I am porting code from VS 6.0 to VS2005. However I am seeing that OnInitDialog() function is not getting called from DoModal() in VS2005.
I already tried adding breakpoints and messagebox to see if OnInitDialog function of CPpSelectDn class is getting called. However I found that it is not getting called.
#include "isodirbrowser.h"
#include "IsoCommonCtl.h"
class CPpSelectDn : public CPropertyPage
{
DECLARE_DYNCREATE(CPpSelectDn)
public:
class CContextInfo
{
public:
SELECTDN sdn;
};
public:
CContextInfo* m_pInfo;
CPpSelectDn();
CPpSelectDn(CContextInfo *pInfo);
~CPpSelectDn();
enum { IDD = IDD_ISOCMN_SELECTDN };
CStatic m_edtBrowserPrompt;
CString m_csBrowserPrompt;
CIsoDirBrowser m_ctlBrowser;
public:
virtual BOOL OnApply();
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
};
------------------------------------------------------------------------------------
#include "stdafx.h"
#include "resource.h"
#include "PpSelectDn.h"
#include "IsoGenericMfc.h"
IMPLEMENT_DYNCREATE(CPpSelectDn, CPropertyPage)
CPpSelectDn::CPpSelectDn() :
CPropertyPage(CPpSelectDn::IDD)
{
}
CPpSelectDn::CPpSelectDn(CContextInfo *pInfo) :
CPropertyPage(CPpSelectDn::IDD),
m_pInfo(pInfo)
{
m_csBrowserPrompt = _T("");
}
CPpSelectDn::~CPpSelectDn()
{
}
void CPpSelectDn::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
DDX_Control(pDX, IDC_ISOCMN_SELDNPROMPT, m_edtBrowserPrompt);
DDX_Text(pDX, IDC_ISOCMN_SELDNPROMPT, m_csBrowserPrompt);
DDX_Control(pDX, IDC_ISOCMN_DIRBROWSER, m_ctlBrowser);
}
BEGIN_MESSAGE_MAP(CPpSelectDn, CPropertyPage)
END_MESSAGE_MAP()
BOOL CPpSelectDn::OnInitDialog()
{
CPropertyPage::OnInitDialog();
SetFontDynamically(this);
AfxMessageBox(L"Simple message box.");
if (m_pInfo->sdn.lpstrTabText)
{
TC_ITEM tcItem;
tcItem.mask = TCIF_TEXT;
tcItem.pszText = (LPTSTR) m_pInfo->sdn.lpstrTabText;
((CPropertySheet*)GetParent())->GetTabControl()->SetItem(0, &tcItem );
}
m_edtBrowserPrompt.SetWindowText(m_pInfo->sdn.lpstrPrompt);
m_ctlBrowser.SetIsoDirInfo(1,(long)(m_pInfo->sdn.nSSLMode));
m_ctlBrowser.SetDefaultFolderFilter(m_pInfo->sdn.lpstrFolderFilter);
m_ctlBrowser.SetSplitMode(FALSE);
m_ctlBrowser.AddDirectory(
m_pInfo->sdn.lpstrTopUrl,
m_pInfo->sdn.lpstrBindUser,
m_pInfo->sdn.lpstrBindPassword);
return TRUE;
}
BOOL CPpSelectDn::OnApply()
{
BOOL bResult = FALSE;
long lCount = m_ctlBrowser.GetSelectedCount(0);
if (lCount > 0)
{
CString csDn = m_ctlBrowser.GetSelectedUrl(0, 0);
_tcsncpy(m_pInfo->sdn.lpstrDn, csDn, m_pInfo->sdn.iMaxDn);
bResult = TRUE;
}
else
{
MessageBox(_T("You must select a directory node or cancel."));
}
if (bResult)
{
bResult = CPropertyPage::OnApply();
}
return bResult;
}
------------------------------------------------------------------------------------
#include "stdafx.h"
#include "resource.h"
#include "IsoGenUtils.h"
#include "IsoCommonCtl.h"
#include "DlgPromptName.h"
#include "PpSelectDn.h"
#include "PpEntryEditor.h"
#include "IsoGenericMfc.h"
#include "DlgFilterEditor.h"
#include "DlgEditReq.h"
ISOCOMMONCTL_DECL BOOL GetDistinguishedName(LPSELECTDN lpsdn)
{
BOOL bResult = FALSE;
if (lpsdn->cbSize == sizeof(SELECTDN))
{
CString csTitle(lpsdn->lpstrTitle);
if (csTitle.GetLength() == 0)
{
csTitle = _T("Browse Directory Folders");
}
CSetModuleHelp modHelp(g_hInstDll);
CPropertySheet sheet(csTitle);
CPpSelectDn::CContextInfo ctx;
ctx.sdn = *lpsdn;
if (!ctx.sdn.lpstrPrompt)
{
ctx.sdn.lpstrPrompt = _T("Select a folder:");
}
CPpSelectDn pageSelect(&ctx);
GenUtilLoadPropPage(g_hInstDll, &pageSelect, pageSelect.IDD);
sheet.m_psh.dwFlags |= PSH_HASHELP;
sheet.AddPage(&pageSelect);
if (sheet.DoModal() == IDOK)
{
_tcsncpy(lpsdn->lpstrDn, ctx.sdn.lpstrDn, lpsdn->iMaxDn);
bResult = TRUE;
}
}
return bResult;
}
Can anyone please help me in understanding why OnInitDialog function of CPpSelectDn class is not getting called when sheet.DoModal() is called? Am I missing something? This used to call OnInitDialog function of CPpSelectDn class correctly when sheet.DoModal() is called with Visual studio 6.0.
modified on Monday, August 30, 2010 10:24 AM
|
|
|
|
|
Please format your code properly so it is readable. Replace the <code></code> tags with the correct <pre></pre> tags. Also use the preview button to check your entry before finally posting it.
It's time for a new signature.
|
|
|
|
|
Normally
CPropertySheet::DoModal() does load the added Pages
from the resource module (that is currently set for the application),
"some other" loaded modules will be also iterated to find them;
but the page can not be found there, I think...
What role has the GenUtilLoadPropPage() , please ?
virtual void BeHappy() = 0;
|
|
|
|
|
GenUtilLoadPropPage loads the Property Page having pageSelect.IDD. When I debugged, it was able to find the resource needed and FindResource() was successful. Wonder why it still does not call the OnInitDialog of CPpSelectDn class though.
ISOGENUTILS_DECL void GenUtilLoadPropPage(HINSTANCE hInst, CPropertyPage *pPage, int nIDTemplate)
{
ASSERT(hInst);
HRSRC hResInfo = ::FindResource(hInst, (LPCTSTR)nIDTemplate, (LPCTSTR)RT_DIALOG);
ASSERT(hResInfo);
HGLOBAL hDialogTemplate = ::LoadResource(hInst, hResInfo);
ASSERT(hDialogTemplate);
LPCDLGTEMPLATE pTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
ASSERT(pTemplate);
pPage->m_psp.dwFlags |= PSP_DLGINDIRECT;
pPage->m_psp.pResource = pTemplate;
pPage->SetHelpID(LOWORD((DWORD)nIDTemplate));
}
|
|
|
|
|
// When I debugged, it was able to find the resource needed and FindResource() was successful.
Was it in the context of the GenUtilLoadPropPage (is?)
or CPropertySheet::DoModal() (should ) ?
Just set a break point at the DoModal()
and then debug inside (by F11)
virtual void BeHappy() = 0;
|
|
|
|
|
I debugged. I see that it calls 'INT_PTR CPropertySheet:: DoModal()' which internally calls CPropertySheet::OnInitDialog().
Here is the stack trace in case this helps you in pointing out any clues:
Code:
> mfc80u.dll!CPropertySheet::OnInitDialog() Line 1437 C++
mfc80u.dll!CPropertySheet::HandleInitDialog(unsigned int __formal=1052816, unsigned int __formal=1052816) Line 1455 C++
mfc80u.dll!CWnd::OnWndMsg(unsigned int message=272, unsigned int wParam=1052816, long lParam=1519392, long * pResult=0x00129744) Line 2194 + 0x8 bytes C++
mfc80u.dll!CWnd::WindowProc(unsigned int message=272, unsigned int wParam=1052816, long lParam=1519392) Line 1741 + 0x17 bytes C++
mfc80u.dll!AfxCallWndProc(CWnd * pWnd=0x84c820c4, HWND__ * hWnd=0x00171098, unsigned int nMsg=272, unsigned int wParam=1052816, long lParam=1519392) Line 243 C++
mfc80u.dll!AfxWndProc(HWND__ * hWnd=0x00171098, unsigned int nMsg=272, unsigned int wParam=1052816, long lParam=1519392) Line 388 + 0x10 bytes C++
mfc80u.dll!AfxWndProcBase(HWND__ * hWnd=0x00171098, unsigned int nMsg=272, unsigned int wParam=1052816, long lParam=1519392) Line 411 + 0x16 bytes C++
USER32.DLL!77e3a454()
[Frames below may be incorrect and/or missing, no symbols loaded for USER32.DLL]
USER32.DLL!77e14750()
USER32.DLL!77e155b0()
NTDLL.DLL!77f91baf()
USER32.DLL!77e16408()
USER32.DLL!77e29da0()
USER32.DLL!77e2cc1e()
USER32.DLL!77e3ed99()
SHLWAPI.DLL!70a9af09()
comctl32.dll!7176b0d7()
comctl32.dll!7174b366()
mfc80u.dll!AfxPropPageCallback(HWND__ * __formal=0x00000000, unsigned int message=0, _PROPSHEETPAGEW * pPropPage=0x00174648) Line 52 + 0x5 bytes C++
comctl32.dll!7174b959()
comctl32.dll!7174b5ef()
comctl32.dll!7174b601()
mfc80u.dll!CComCtlWrapper::_PropertySheetW(const _PROPSHEETHEADERW * unnamed1=0x00129bc4) Line 342 + 0x6e bytes C++
mfc80u.dll!CPropertySheet::DoModal() Line 961 C++
IsoGenU.dll!GetDistinguishedName(tagSELECTDN * lpsdn=0x0012a800) Line 137 + 0xb bytes C++
I also saw that CPropertyPage::OnSetActive() was called by CPropertySheet:: DoModal(). As can be seen above, CPropertySheet::OnInitDialog() is getting called. However, OnInitDialog function of CPpSelectDn class is not getting called.
|
|
|
|
|
Here is what I did with VS6.0:
- As I mentioned earlier, it was working fine with VS6.0. So What I did now is , I created a fresh VS6.0 setup on a new machine and built the code. But when I tested, again I was facing same display problem as I was getting with VS2005. However, I saw below warnings in the VS6.0 output window:
CoCreateInstance of OLE control {395262A9-51B1-11D2-BA1B-00A02489AC7A} failed.
>>> Result code: 0x800401f0
>>> Is the control is properly registered?
Warning: CreateDlgControls failed during dialog init.
So I registered the IsoDirB.ocx file using regsvr32.exe manually. Then when I tested the application with VS6.0, it worked correctly and the UI problem with Directory browser display was not there and everything worked just nicely. So this meant that if IsoDirB.ocx control is not registered, then I see UI problem with Directory browser display.
-------------------------------------------------------------------
From above findings, I also registered the IsoDirB.ocx file using regsvr32.exe manually on VS2005 machine too. It didn't give any error when I registered IsoDirB.ocx using regsvr32.exe on VS2005 machine. Then when I tested the application. However, I am still seeing the same display problem with Directory browser display with VS2005.
I see below warnings in the VS2005 output window:
'mm.exe': Loaded 'C:\Program Files\CriticalPath\Manager\IsoDirB.ocx', No symbols loaded.
First-chance exception at 0x77fac57c in mm.exe: 0xC0000139: Entry Point Not Found.
'mm.exe': Unloaded 'C:\Program Files\CriticalPath\Manager\IsoDirB.ocx'
I am not sure how much important/relevance above warning has with the UI problem; but this might be important. I remember I made changes in build of IsoDirB.ocx code project and not sure if it is causing this first chance exception. Any inputs on investigating about this "Entry Point Not Found" warning are highly appreciated.
|
|
|
|
|
It is working fine now. I unregistered the ocx control, then rebuilt the control and then registered it with regsvr32.exe. Now OnInitDialog of CPpSelectDn is getting called. Also, the UI controls for LDAP directory browse are shown correctly on the page. It looks like earlier it had old incorrect version of ocx file registered, which needed unregistering and reregistering the new one.
|
|
|
|
|
Hi all,
I am using Install shiield 2010 to create a setup file.
In install shield i will add all the dlls,exe and create a setup file,
So that in other system,i acn just run the setup file and use the exe.
But if any changes in the application,i dnt want to again run the install shield to just replace exe.
Is there anyother option to create a setup file through Install shield.
Where in other system i cn just replace the exe in the folders and run the setup/
Thanks
Raj
|
|
|
|
|
raju_shiva wrote: Where in other system i cn just replace the exe in the folders and run the
setup/
totally depend on type of install shield package you are using, if it store it's file in zip file, replace the file. that will do!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hello there I have a issue related to the usage of the bitmap enabled Dialog window.I have created a keyboard type layout and i wish to get the input through keyboard also.When i use the mouse I am able to get the button(s) pressed and also all the buttons are working fine - the other images DEFAULT,SELECTED,DISABLED ..all get loaded and work since I am using the function here m_BtnBtn1Ctrl.LoadBitmaps ,But then any key pressed on keyboard and the corresponding character on the screen isn't able to do the same as I have been able to do it with clicking of the mouse(and using the Loadbitmaps() function ).
I am using these 3 functions to achieve the same action and effect as that using a mouse
LoadBitmap()
SetBitmap()
Invalidate()
I also tried this piece of code
HBITMAP hbm = (HBITMAP)LoadImage(NULL, "\\res\\Selected\\bitmap21.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
and
bitmap.Attach((HBITMAP)LoadImage(NULL, "\\res\\Selected\\bitmap21.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION));
but these don't seem to give the pressed button effect though internally they work.Can some one please help me with this
Thanks and regards Sayonee
====RELATED CODING PART==========
BOOL KeyBoard_press::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
CString strTemp;
if (pMsg->message == WM_KEYDOWN)
{
if ( pMsg->wParam == 0x41 || pMsg->wParam == 0x61) //check for both 'a' and 'A'
OnBtnBtn1();
if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_DELETE ||
pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_TAB ||
pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN || GetKeyState (VK_CONTROL))
{
::TranslateMessage (pMsg);
::DispatchMessage (pMsg);
return TRUE; // DO NOT process further
}
}
return CDialog::PreTranslateMessage(pMsg);
}
|
|
|
|
|
This is the third time that you post this question on this forum, and you posted it aloso in the Q&A.
I suggest you to make your question too clear, rather than insisting in post it as is. And again, if something on an answer is not clear, add a comment to that answer: who wrote it probably could add more explainations.
|
|
|
|
|
Hello experts,
I recently solved my duplicate includes problem using the #ifndef-#define-#endif pre-processors.
However, this somehow causes a problem if classes from the same .h file should be used by different .cpp files.
The first .cpp file including the .h file gets compiled, but the others throw an "undefined reference" compile error.
It's as if I never included the .h file on the other files.
How can I overcome both duplicate includes and single includes problems?
A bit on my workstation:
OS: Ubuntu.
IDE: Eclipse.
Compiler: g++
Thanks in advance,
Shy.
|
|
|
|
|
Shy Agam wrote: However, this somehow causes a problem if classes from the same .h file should be used by different .cpp files.
The first .cpp file including the .h file gets compiled, but the others throw an "undefined reference" compile error.
It's as if I never included the .h file on the other files.
That's not how include guards work. They prevent including the same header file in one compilation unit (thus, one cpp file) but doesn't prevent multiple cpp files to include the same header file.
|
|
|
|
|
Did you use the guards properly, e.g.
#ifndef _MYCLASSES_H_
#define _MYCLASSES_H_
#endif // _MYCLASSES_H_
#include "myclasses.h"
#include "myclasses.h"
?
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 articles]
|
|
|
|
|
Indeed.
However, I neglected to mention that the headers and their .cpps are in one shared-library project, and there's another project using this library.
The other project is the one which fails to compile.
It seems that this is some kind of linkage problem of some sort, but I can't figure it out.
I copied the main file form my executable project into the library project, just to see if it compiles, and it compiled perfectly.
Might I be missing on a specific linkage configuration?
|
|
|
|
|
Shy Agam wrote: It seems that this is some kind of linkage problem of some sort, but I can't figure it out.
Please, post the full error message.
This confirms that the problem has nothing to do with include guards, otherwise you would get a compilation error, not a linker error.
Are you sure you linked correctly to the library ?
|
|
|
|
|
#include <HeaderFileFromLibrary.h>
using namespace NamespaceFromHeaderFile;
int main(int argc, char **args)
{
ClassFromHeaderFile *pClass = ClassFromHeaderFile::GetInstance();
.
.
.
return 0;
}
The first row in main throws the following compile error:
undefined reference to `NamespaceFromHeaderFile::ClassFromHeaderFile::GetInstance()'
Cedric Moonen wrote: Are you sure you linked correctly to the library ?
AAMOF I'm not experienced with C++ coding.
As I am an experienced developer in other languages, I can write proper code (Or so I would like to think ), but I don't have the experience for configuring my projects properly.
As far as I can tell I did link the library correctly.
Any way to make sure of it?
modified on Monday, August 30, 2010 7:40 AM
|
|
|
|
|
Shy Agam wrote: As far as I can tell I did link the library correctly.
How did you do it ? I am not experienced with g++ so I don't know exactly how to specify library to link.
From the error you get, chances are that you didn't link to the library properly.
|
|
|
|
|
Are you sure you are using the ClassFromHeaderFile definitions correctly. Is GetInstance() a static member with public visibility?
It's time for a new signature.
|
|
|
|
|
No, what he's getting is an linker error. You either do not link the library which contains the definition, or you're linking in wrong order, or you haven't configured your linker properly. Please, post the makefile (or the command line) you are using to build and link the program.
|
|
|
|
|
paul_71 wrote: No, what he's getting is an linker error.
His messages are not clear as to whether this is a compiler or linker error. BTW this message should have been in reply to the OP not to me.
It's time for a new signature.
|
|
|
|
|
Sorry, these hierarchical"replies" suck!
|
|
|
|
|
paul_71 wrote: these hierarchical"replies" suck!
Well, they take a bit of getting used to, but sometimes they work better than the other style.
It's time for a new signature.
|
|
|
|
|