|
Don't you use new without delete ?
"Gods die, when their believers are gone." --from Sandman by Neil Gaiman
|
|
|
|
|
hi,
i want to know how to get the message after window has been shown. i have checked out with OnShowWindow, WindowPosChanged ... seems that all can report me the Window is about to be shown. that's not ok... as i want to do sth after the window already being seen by the user.
any help?
thanks,
jim
|
|
|
|
|
OnDestroy()
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
hi..
void CEditorView::OnInitialUpdate()<br />
{<br />
CScrollView::OnInitialUpdate();<br />
<br />
SetScrollSizes(MM_LOENGLISH, CSize(2020, 1020));<br />
}<br />
in the above code..i wanna know when i set the mapping mode to MM_LOENGLISH, the param that i supply...are they depicted in mapping mode as i entered??or are they changed to mapping mode params and then entered??
for eg..above is the mapping mode taken in, is it exacly 2020 and 1020 in MM_LOENGLISH???
or is it converted to LOENGLISH and the value has changed to LOENGLISH and is no longer 2020 by 1020???
i gues its a more of my understanding prob...can someone pls help???tks....
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
hi...i am facing a small prob..
void CEditorView::OnDraw(CDC* pDC)<br />
{<br />
CEditorDoc* pDoc = GetDocument();<br />
ASSERT_VALID(pDoc);<br />
<br />
pDC->SetMapMode(MM_LOENGLISH);<br />
<br />
CPoint pos;<br />
pos.x = pDoc->GetGridWidth()*100;<br />
pos.y = pDoc->GetGridHeight();<br />
pDC->DPtoLP(&pos);<br />
<br />
CRect rect(10, -10, 2000, -1000);<br />
pDC->Rectangle(rect);
when i do this
CRect rect(10, -10, pos.x, pos.y);
the rectangle that is drawn isboundless...i.e no mater how long i put the scroll bars..i still cant see the end of therect..wherea as if i do this
CRect rect(10, -10, 2000, 1000);
i can see the rectangle...
why is that???why cant i see the rect when iuse the first method??
tks for any help...
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
Hi, all
I want to make wrapper member function
like this,
class A
{
int Xsprintf (char * pszDest,const char * pszFormat, ...)
{
// this might not right, but I want like this...
sprintf( pszDest, pszFormat, ... );
}
};
How do I can this?
thanks!
|
|
|
|
|
Only way to avoid using va-arg, is to avoid variable number of arguments.
If you have some specific setups, you could say
XSprintf(char * output, char * format, int I1, int I2){
sprintf(output, format, I1, I2);
}
and
XSprintf(char * output, char * format, int I1, int I2, int I3){
sprintf(output, format, I1, I2, I3);
}
but this is not very flexible. For every kind of argument, you need new Xsprintf definition. May be good enough, tho.
|
|
|
|
|
Create an ovcerload for sprintf in your project.
In stdio.h sprintf has only one prototype so
int CYourAppSDI::sprintf(CString str)
{
}
would work or
int CYourAppSDI::sprintf(int nVar)
{
}
would work or
int CYourAppSDI::sprintf(CString str,int nVar)
{
}
would work right?
Now their are some good replacements for sprintf on this site and others.
So all you have to do is write or copy the code inside your overload.
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
This was talked about (unsuccessfully) here.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Review your design constraints. By excluding the use of va_arg, you are making the problem very hard if not impossible (excluding the use of hacks and kludges).
Don't shoot yourself in the foot by using silly design constraints.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi All,
Does anyone know why I would get a first chance exception occur when I try to get the current Username in a COM object I have? the error message is as follows:
First-chance exception in app.exe (SECUR32.DLL): 0xC0000005: Access Violation.
The program 'C:\app.exe' has exited with code 0 (0x0).
when all I am trying to do is
LPTSTR username;
DWORD cchBuff = 1024;
BOOL result = GetUserName(username, &cchBuff);
thanks for your help
cheers
Bryce
|
|
|
|
|
|
Hi Michael,
Thanks, you are indeed correct.
below is what is needed to be done:
<br />
LPTSTR username;<br />
DWORD cchBuff = 1024;<br />
TCHAR tchBuffer[1024]; <br />
<br />
username = tchBuffer;
BOOL result = GetUserName(username, &cchBuff);<br />
cheers
Bryce
|
|
|
|
|
#define MAX_LEN 255
CString str;
char ch[MAX_LEN];
DWORD dwNameSize = MAX_LEN;
GetUserName(ch, &dwNameSize);
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
Hi Guys
I have made my custom resizable combo box. I want to display a gripper in top right corner but windows don't has any in built style for that.
Can anyone guide me how to bring a gripper in top right corner.
can we rotate it some how using the funtion : SetWorldTransform
or is there some other possible way out
|
|
|
|
|
First of all I am new to C++ and in particular MFC, but I am making some minor changes to a project that I downloaded from here and the final change I need to make is to ask the user a question right after the dialog has loaded. In Visual FoxPro I would put this in the Activate of the Dialog, but in MFC this causes a multitude of issues such as:
1. The dialog doesn't actually display, so there is just a MessageBox in the middle of the screen. - The dialog displays after I click OK on the message which is understandable.
2. The Activate runs many times while the dialog is loading which causes any code I put in there to run many times (I put a flag in there to make it run only once.)
My OnActivate is shown bellow:
<br />
afx_msg void CdotNetInstallerDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimised)<br />
{<br />
CDialog::OnActivate(nState, pWndOther, bMinimised);<br />
<br />
if (m_bRunFromReboot)<br />
{<br />
m_bRunFromReboot = false;<br />
if (MessageBox("Continue with installation?", "Requirements Checker", MB_YESNO | MB_ICONQUESTION) == IDYES)<br />
ResumeInstall();<br />
}<br />
return;<br />
}<br />
Can somebody please tell me where I should put this code? I have figured that putting it in OnActivate is probably wrong.
Thanks,
Chris Ormerod
|
|
|
|
|
Thanks to GeMe_Hendrix about 10 posts below this one I have the answer (I should look before I post):
Try creating your own custom message ad handler for it first therefore at the top of your dialog CPP file...
#define WM_MYOWNMESSAGE WM_USER + 1001;
... Then in the header file put...
afx_msg LRESULT OnMyOwnMessage(WPARAM wParam, LPARAM lParam);
...Then the appropriate body for it...
LRESULT CMyDialog::OnMyOwnMessage(WPARAM wParam, LPARAM lParam)
{
... Show the file dialog box (I know it has to be modal)
return 0;
};
... And finally in the body put...
ON_MESSAGE(WM_MYOWNMESSAGE, OnMyOwnMessage)
... in the BEGIN_MESSAGE_MAP section...
... To call the message handler put this in the OnInitDialog function just before it returns...
PostMessage(WM_MYOWNMESSAGE, 0, 0);
And as a bonus I got an explanation of the message queue.
Chris.
|
|
|
|
|
Hi All,
I have a question on the following code.
class ClassA<br />
{<br />
virtual void TestA()=0;<br />
};<br />
<br />
class ClassB: public ClassA<br />
{<br />
virtual void TestA();<br />
ClassB();<br />
virtual ~ClassB();<br />
void PrintB();<br />
};<br />
<br />
void ClassB::TestA()<br />
{<br />
cout << "TestA is Called from ClassB"<<endl;<br />
return;<br />
}<br />
<br />
void ClassB::PrintB()<br />
{<br />
cout << "PrintB is called" << endl;<br />
return;<br />
}<br />
<br />
class ClassC: public ClassA<br />
{<br />
virtual void TestA();<br />
ClassC();<br />
virtual ~ClassC();<br />
void PrintC();<br />
};<br />
<br />
void ClassC::TestA()<br />
{<br />
cout << "TestA is Called from ClassC" << endl;<br />
return;<br />
}<br />
<br />
void ClassC::PrintC()<br />
{<br />
cout << "PrintC is called" << endl;<br />
return;<br />
}<br />
<br />
ClassA *pB;<br />
ClassA *pC;<br />
<br />
pB = new ClassB();<br />
pC = new ClassC();<br />
<br />
pB->TestA();
pC->TestC();
<br />
pB->PrintB();<br />
pC->PrintC();
In the above code, I am getting compilation errors as commented in the code. Is there anyway of calling methods of inherited class with a pointer to the base class?
My requirement is to call appropriate inherited class at runtime basing upon the user input with a single pointer to a base class. i.e
ClassA *pGeneric;<br />
if(user_input == 1)<br />
pGeneric = new ClassB()<br />
else<br />
pGeneric = new ClassC();
This works when the both inherited classes have the same methods but fails if inherited class an extra method. Is there any way to call one of the inherited classes during runtime with a SINGLE pointer to base class?
First of all, I want to know is it possible to do in C++? If it is possible, please suggest me the approach to take.
Please help me out. Please suggest me any other methods that provide the same functionality.
Thanks in Advance,
Anil
|
|
|
|
|
you can use dynamic_cast to see if the class is indeed of a particular derived type, then cast it to make the call. If you want the functionality to be available from a base class instance, the method needs to be in the base class.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi Chris, Thank you for your email. Could you please tell me how to declare the pointer variable for dynamic cast?
Thanks,
Anil
|
|
|
|
|
Hi Chris,
I found information about dynamic cast in MSDN. Thank you very much!!
Anil
|
|
|
|
|
Hello,
Has anyone figured out how to make a CScrollView (or better yet a CFormView) work with a CHeaderCtrl? When I try it, the header scrolls with the view, instead of staying put like a good header should.
In my application, each row is a dynamically created child window, a bit like a modeless dialog, containing child controls. With CFormView, I just attach my child windows to the view, using SetParent, and they become part of the form; when I scroll the view, the child windows automatically scroll too. It's magic.
You may be wondering, why don't I use an ownder-drawn CListView? The header would be easy then. All of my rows are the same height, so it makes sense, but it doesn't work: when I scroll the list, my child windows don't get painted, no matter what I do. I tried attaching my child windows directly to the view's CListCtrl, instead of to the view, but it didn't help.
Any advice would be greatly appreciated!
~CK
|
|
|
|
|
The Header should not be the child of CFormview , make it child of mainframe and handle onsize event in mainframe to size header and formview so that they are both visible.
it works
|
|
|
|
|
Thank you! The fix almost works, but there's one serious problem. About half the time, when I press Alt-N to create a new document, the view overwrites my header. Would it help if I sent you my test project? At this point it's just a few lines really.
Also I don't understand why my CHeaderCtrl's captions displaying in bold instead of the usual system font? I assume CListCtrl does something that I'm not doing, but I can't figure out what.
~CK
PS here's my OnCreate and OnSize code:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// create header control
CRect r;
GetClientRect(r);
r.bottom = HEADER_HEIGHT;
m_Hdr.Create(WS_CHILD | WS_VISIBLE, r, this, 0);
HDITEM hdi;
const cols = 3;
LPCSTR str[cols] = {"Volume", "Pan", "Pitch"};
int wid[cols] = {172, 172, 172};
hdi.mask = HDI_TEXT | HDI_WIDTH | HDI_FORMAT;
hdi.fmt = HDF_LEFT | HDF_STRING;
for (int i = 0; i < cols; i++) {
hdi.pszText = (char *)str[i];
hdi.cchTextMax = strlen(str[i]);
hdi.cxy = wid[i];
m_Hdr.InsertItem(i, &hdi);
}
return 0;
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
// shrink view vertically to make room for header
CView *vp = GetActiveView();
if (vp != NULL) { // need this or it crashes
CRect r;
vp->GetWindowRect(r);
ScreenToClient(r);
r.top += HEADER_HEIGHT;
vp->MoveWindow(r);
}
// stretch header horizontally to fill our client area
if (IsWindowVisible()) { // need this or it crashes
CRect r, cr;
GetClientRect(cr);
m_Hdr.GetWindowRect(r);
ScreenToClient(r);
r.right = cr.right;
m_Hdr.MoveWindow(r);
}
}
|
|
|
|
|
try to create a brand new font via LOGFONT and the set it using setfont and keep cfont a member of mainframe
should work
regarding ctrl-N ,
i would create two new windows in CView as the cviews child
one the header and other the window that you want and the ndo the scrolling in window not in cview this would be safe against ctrl-n
but you can modify onNewDocument to suit ur needs
|
|
|
|
|