|
OK, I'll try renaming them (although CHAR works fine for other templates).
I'll see if I can reproduce that in VC6 in an minimum environment, and if if so, try VC7.
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Hi everybody,
I've got a strange behavior with my code.
I have a dialog-based program, which opens another dialog (modal) when the user click on the right menu item.
There, OnInitDialog() is called before the new dialog is displayed, and it it there where I initialize my dialog depending on how the dialog was created.
I do a set of LoadString() to display the texts of the dialog in the correct language. but after loading the strings, SetWindowText() crashes.
here is the code :
Call of the new dialog :
<font color=#0000FF>void</font> CFactEditorDlg::OnFileOpen() {
COpenFilesDlg dlg(m_strDBFile, m_strDestFile);
<font color=#0000FF>if</font> (dlg.DoModal() == IDOK) {
<font color=#008000>
}
}
New dialog's initialisation :
BOOL COpenFilesDlg::OnInitDialog() {
CDialog::OnInitDialog();
<font color=#008000>//...</font>
CString strWindowText;
strWindowText.LoadString(IDS_OFD_FACT_RECSTAT); m_psrFact->SetWindowText(strWindowText);
strWindowText.LoadString(IDS_OFD_DB_RECSTAT); m_psrDataBase->SetWindowText(strWindowText);
strWindowText.LoadString(IDS_OFD_PROMPT); m_psFactPrompt->SetWindowText(strWindowText);
m_psDBPrompt->SetWindowText(strWindowText);
<font color=#FF0000>-></font> strWindowText.LoadString(IDS_OFD_PREVIEW_BTN); m_pbPreviewFact->SetWindowText(strWindowText);
<font color=#008000>//...</font>
}
The real place having problem :
<font color=#0000FF>void</font> CWnd::SetWindowText(LPCTSTR lpszString) {
<font color=#FF0000>-></font> ASSERT(::IsWindow(m_hWnd));
<font color=#0000FF>if</font> (m_pCtrlSite == NULL)
::SetWindowText(m_hWnd, lpszString);
<font color=#0000FF>else</font>
m_pCtrlSite->SetWindowText(lpszString);
}
what does it mean ???
few day ago, this code was working well, and today, when i was updating another class of the program (which have no relation of any order with this one), it stops me there now...
can anyone help of any kind please ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Is m_pbPreviewFact mapped to a valid control? In other words, you've probably got a DoDataExchange() method that looks similar to:
void COpenFilesDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, SOME_ID_HERE, m_pbPreviewFact);
} Look to make sure that SOME_ID_HERE is in the project's resource.h file with a unique number, and that it is also in the dialog's template in the project's .rc file.
toxcct wrote:
few day ago, this code was working well, and today, when i was updating another class of the program (which have no relation of any order with this one), it stops me there now...
What happens if you remove this class? Does the SetWindowText() call start working again?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
yes it does.
i put comments in the code sample, but before i do this into OnInitDialog() , I do :
pbPreviewFact = (CButton*)GetDlgItem(IDC_PREVIEW_BTN); i don't understand... the assert failure is like pbPreviewFact is not a window, but it actually is... !
the worst is that i didn't even modify this class !!!
I was only working on another new dialog, with no relationship with this one...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
i have another strange fact :
if i move the line (in my code) that is giving me an error, i still have an error at the same line !!!, that means on another code line ! any idea ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Comment out each of the SetWindowText() statements and recompile. Does the problem go away? If so, remove the comment from each statement individually and see which causes the problem to start.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Also try "rebuild all." One of my pet peeves with VC6 is that it will not allow one to make Resource.h a dependency. That thoroughly annoys me. I can understand the rationale to not want it to be but to prohibit it from being one is stupid I think.
|
|
|
|
|
|
Rick York wrote:
One of my pet peeves with VC6 is that it will not allow one to make Resource.h a dependency.
In all of my projects, resource.h is indeed in the dependency list. What am I missing here?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Does anyone know of a good piece of code for formating phone numbers. By good, I mean formating based on country code (at the very least). Most of the hits I am seeing, on the WWW, seem to think it is pretty neat to be able to format a US phone number, but any programmer can do that (if someone cann't, there not a programmer).
Thanks for any help!
John R. Shaw
"If I was at home, I would not be Anonymous."
|
|
|
|
|
See the discussion here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks David, thats about what I thought!
According to every thing I have now read even Microsoft cann't do it, except for certain countries with fixed formats (and problems may occur even for those). There is no garantee that any format will not change in the future; thereby breaking code depending on it.
John R. Shaw
"If I was at home, I would not be Anonymous."
|
|
|
|
|
Hi,
I'm havin a silly problem with a scroll bar. It works but it never scrolls all the way to the maximum range value.
For example here's the code:
<br />
SCROLLINFO ScrollInfo;<br />
ScrollInfo.cbSize = sizeof(ScrollInfo); <br />
ScrollInfo.fMask = SIF_ALL; <br />
ScrollInfo.nMin = 0; <br />
ScrollInfo.nMax = 125<br />
ScrollInfo.nPage = ScrollInfo.nMax / 10;<br />
ScrollInfo.nPos = 0;<br />
ScrollInfo.nTrackPos = 0; <br />
m_ImageHorizontalScroll.SetScrollInfo(&ScrollInfo); <br />
int result = m_ImageHorizontalScroll.SetScrollPos(10);
result = m_ImageHorizontalScroll.SetScrollPos(123);
result = m_ImageHorizontalScroll.GetScrollPos();
So I have to set the nMax to my value + a fudge number? What should that number be?
Thanks.
|
|
|
|
|
I have this code to change screen resolution, and it works for win98/2000
but it does not work for WinXP knowing that i log in as Administrator.
<br />
DEVMODE dm;<br />
dm.dmFields=DM_PELSWIDTH|DM_PELSHEIGHT;<br />
dm.dmPelsHeight=600;<br />
dm.dmPelsWidth=800;<br />
ChangeDisplaySettings(&dm,0);
can anybody tell me whats wrong with this code, or another way that may work?
thanx all
Mohammad
A candle looses nothing by lighting another candle
|
|
|
|
|
Mohammad A Gdeisat wrote:
but it does not work...
What does ChangeDisplaySettings() return?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
thanx DavidCrow,
the strange thing is that ChangeDisplaySettings(...) returns DISP_CHANGE_SUCCESSFUL, and ofcourse, i dont see any results on my screen.
have any info?
thank you very much
Mohammad
|
|
|
|
|
I have this class declared as
-------------------------------------------------------------------
class CMyArray : public CTypedPtrArray< CObArray, CMyDataClass* ><br />
{<br />
public:<br />
...<br />
CMyArray();<br />
virtual ~CMyArray();<br />
protected:<br />
...<br />
};
-------------------------------------------------------------------
where the CMyDataClass is declared as
-------------------------------------------------------------------
class CMyDataClass:public CObject<br />
{<br />
public:<br />
CMyDataClass( );<br />
virtual ~CMyDataClass( );<br />
... <br />
protected:<br />
... <br />
};
-------------------------------------------------------------------
Upon compile I get this error:
error C2653: 'CMyArray' : is not a class or namespace name
What?! The strangest thing is that I have other classes defined in the exact same way, compiling without problems.
I searched the documentation using the error code for keyword and found some vague references to this being a known bug, but I could not work out a solution from the text. Obviously, I am doing something wrong with the CMyDataClass, since I do get the exact same construction to work with other generic classes.
------------------------------------------------------------
"Pooollyyy!! ...Polly Parrot! Wakey-wakey!"
|
|
|
|
|
I am using folowing code to insert BMP in RichEdit.
InsertPlotBitmap(CString szFileName)
{
USES_CONVERSION;
SCODE sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &m_lpLockBytes);
if (sc != S_OK)
AfxThrowOleException(sc);
ASSERT(m_lpLockBytes != NULL);
sc = ::StgCreateDocfileOnILockBytes(m_lpLockBytes,
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &m_lpStorage);
if (sc != S_OK)
{
VERIFY(m_lpLockBytes->Release() == 0);
m_lpLockBytes = NULL;
AfxThrowOleException(sc);
}
// CString szFileName=strSmile;
// attempt to create the object
sc = ::OleCreateFromFile(CLSID_NULL, T2COLE(szFileName),
IID_IUnknown, OLERENDER_DRAW, NULL, NULL, m_lpStorage, (void **) &m_lpObject);
if ( sc != S_OK )
{
TCHAR * lpMsgBuf;
::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM, NULL,
::GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf, 0, NULL );
CString msg( lpMsgBuf );
msg += _T("\n\n\n" );
msg += szFileName;
AfxMessageBox( msg, MB_OK );
::LocalFree( lpMsgBuf );
return;
}
// m_lpObject is currently an IUnknown, convert to IOleObject
if (m_lpObject != NULL)
{
LPUNKNOWN lpUnk = m_lpObject;
m_lpObject = QUERYINTERFACE(lpUnk, IOleObject);
lpUnk->Release();
if (m_lpObject == NULL)
AfxThrowOleException(E_OUTOFMEMORY);
}
// cache the IViewObject interface
m_lpViewObject = QUERYINTERFACE(m_lpObject, IViewObject2);
if (m_lpViewObject == NULL)
return;
// setup for advises; we assume that OLE cleans them up properly
LPADVISESINK lpAdviseSink =
(LPADVISESINK)GetInterface(&IID_IAdviseSink);
// set up view advise
VERIFY(m_lpViewObject->SetAdvise(DVASPECT_CONTENT, 0, lpAdviseSink)
== S_OK);
// the server shows these in its user-interface
// (as document title and in File Exit menu)
m_lpObject->SetHostNames(T2COLE(AfxGetAppName()),
T2COLE(_T("Test")));
// all items are "contained" -- this makes our reference to this object
// weak -- which is needed for links to embedding silent update.
OleSetContainedObject(m_lpObject, TRUE);
// CHARRANGE cr;
//m_Ctrl_RichEdit.GetSel( cr );
//cr.cpMin = cr.cpMax -1;
//m_Ctrl_RichEdit.SetSel( cr );
REOBJECT reo;
memset( &reo, 0, sizeof( reo ) );
reo.cbStruct = sizeof( reo );
CLSID classID;
if ( m_lpObject->GetUserClassID( &classID ) != S_OK)
classID = CLSID_NULL;
reo.clsid = classID;
reo.cp = REO_CP_SELECTION;
reo.poleobj = m_lpObject;
reo.pstg = m_lpStorage;
LPOLECLIENTSITE lpClientSite;
GetIRichEditOle()->GetClientSite( &lpClientSite );
reo.polesite = lpClientSite;
SIZEL sizel;
sizel.cx = sizel.cy = 0; // let richedit determine initial size
reo.sizel = sizel;
reo.dvaspect = DVASPECT_CONTENT;
reo.dwFlags = REO_RESIZABLE;
reo.dwUser = 0;
HRESULT hr = GetIRichEditOle()->InsertObject( &reo );
}
This code works fine if i call from same window.But it gives error if i invoke from another dialog it gives error in the following line .
GetIRichEditOle()->GetClientSite( &lpClientSite );
can any body help me .
Learner always
|
|
|
|
|
rver wrote:
But it gives error...
And what would that error be?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
It Gives "Assertion Failed" in following function
IRichEditOle* CRichEditCtrl::GetIRichEditOle() const
{
ASSERT(::IsWindow(m_hWnd));
...
}
As in this it cannt get m_hWnd is 0x00000000.
Learner always
|
|
|
|
|
hi all,
how to prevent mfc dialog based app beign displayed on taskbar ?
Either when maximised and minimised.
Thanks.
|
|
|
|
|
hi friend,
I quote the folowing from MSDN 2003, I dont know if it really works but I hope so:
I will simply tell you the answer: you must create your dialog as a child of an invisible window that has WS_EX_TOOLWINDOW set, and you must make sure your dialog has the WS_EX_APPWINDOW style turned off. If you read the documentation’s fine print, you might figure this out—but only if you use a powerful magnifying glass.
<br />
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)<br />
{<br />
if (CFrameWnd::PreCreateWindow(cs)) {<br />
cs.dwExStyle |= WS_EX_TOOLWINDOW;<br />
return TRUE;<br />
}<br />
return FALSE;<br />
}<br />
.<br />
.<br />
.<br />
<br />
BOOL CMyApp::InitInstance()<br />
{<br />
CMainFrame* pFrame = new CMainFrame;<br />
m_pMainWnd = pFrame;<br />
pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPED, NULL, NULL);<br />
CMyDlg dlg(pFrame);<br />
int nResponse = dlg.DoModal();<br />
if (nResponse == IDOK) {<br />
} else if (nResponse == IDCANCEL) {<br />
}<br />
return FALSE;<br />
}
hope it helps
good luck
A candle looses nothing by lighting another candle
|
|
|
|
|
hi friend,
I found something on MSDN 2003 and i hope its helpful:
quote says:
I will simply tell you the answer: you must create your dialog as a child of an invisible window that has WS_EX_TOOLWINDOW set, and you must make sure your dialog has the WS_EX_APPWINDOW style turned off. If you read the documentation’s fine print, you might figure this out—but only if you use a powerful magnifying glass.
<br />
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)<br />
{<br />
if (CFrameWnd::PreCreateWindow(cs)) {<br />
cs.dwExStyle |= WS_EX_TOOLWINDOW;<br />
return TRUE;<br />
}<br />
return FALSE;<br />
}<br />
.<br />
.<br />
.<br />
BOOL CMyApp::InitInstance()<br />
{<br />
CMainFrame* pFrame = new CMainFrame;<br />
m_pMainWnd = pFrame;<br />
pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPED, NULL, NULL);<br />
CMyDlg dlg(pFrame);<br />
int nResponse = dlg.DoModal();<br />
if (nResponse == IDOK) {<br />
} else if (nResponse == IDCANCEL) {<br />
}<br />
return FALSE;<br />
}
I hope its helpful
Mohammad.
A candle looses nothing by lighting another candle
|
|
|
|
|
I have a SDI project. When I run the project there is a resource loaded that appears in the main window that has buttons, edit boxes, list boxes, etc....the user interface. I have never really understood where in the code or when a resource is loaded so that it appears in the main window. Can someone help me with this?
Thanks.
Jerry
|
|
|
|
|
Assuming you are talking about a CFormView app.
The resource is loaded and created in the CFormView::Create function. (viewform.cpp)
Which is called from the CMainFrame::OnCreate function via the CFrameWnd::OnCreate call.
Michael
CP Blog [^]
|
|
|
|
|