1. I didn't copy the whole code, just the snippet. 2. Yes, I did. That's how I could state 'it stays as NULL before and after the call'. 3. I do. Thanks. 4. Same reason as number 1 above. Anyway, I solved it as pointed by CPallini below. I was missing the ampersand symbol to indicate passing by pointer. Thanks anyway.
Joe Smith IX
Posts
-
Pass by pointer not working -
Pass by pointer not workingAh, you are right. To pass by address, I need the & character. It's working fine now. Thanks so much.
void CMyApp::CallDlg(int nType, CMyDlg* &pDlg)
{
// ...
} -
Pass by pointer not workingHi all, I have a variable declared:
CMyDlg* m_pDlg1;
I initialized it as NULL and expected it to change when passed to CallDlg. But it stays as NULL before and after the call, therefore creating new modeless CMyDlg everytime it gets called (instead of bringing up the existing one the foreground). What did I do wrong? Shouldn't m_pDlg1 point to the newly created dialog? Please help. Thanks in advance.
void CMyApp::ActivateDlg1()
{
CallDlg(1, m_pDlg1); // the variable stays as NULL
}void CMyApp::CallDlg(int nType, CMyDlg* pDlg)
{
if(pDlg) pDlg->SetForegroundWindow(); // This never gets called
else
{
pDlg = new CMyDlg(nType);
if(!::IsWindow(pDlg->GetSafeHwnd())) pDlg->Create(IDD_MY_DLG, NULL);
}
} -
TextOut/DrawText is too slowOK guys, thanks for the pointers. Let me try that approach.
-
TextOut/DrawText is too slowHello, I am looking into a full-screen text scrolling app, and found this at code project: [^] It is simple and fits my need. The only problem is that when I maximize it, its scrolling speed is way too slow (even when I take off the image and the delay iss set to 1ms). Can anyone give me some hints or pointers (sample code, maybe) on how I can make it faster? Thanks in advance.
-
How to calculate average of qty sold the last 6 months or lessThanks a lot. Your answer pointed me to the answer I am looking for.
-
How to calculate average of qty sold the last 6 months or lessThanks a lot. Your answer pointed me to the answer I am looking for.
-
How to calculate average of qty sold the last 6 months or lessTable [Sold]
ID PID Qty Date
1 1 8 jun 1, 2010
2 3 5 jul 1, 2010
3 3 2 aug 1, 2010
4 1 1 sep 1, 2010
5 3 4 sep 30, 2010
6 2 3 oct 8, 2011
7 2 5 nov 1, 2011
8 3 2 dec 1, 2011
9 1 8 jan 1, 2011
10 2 5 feb 1, 2011Hi all, I have difficulty composing a rather complex (for me) query. I would like to know the average qty sold of each PID per day based on the last 6-month data. If data is less than 6 month, then adjust accordingly. So on the data above: Today: Mar 24, 2011 6-month cut-off: Sep 24, 2010 I want to get:
PID Qty/day
1 8/182 = 0.0440
2 (3+5+5)/168 = 0.0774 -> 168: because the oldest sale is oct 8
3 (4+2)/182 = 0.0330Is there any way I can do this? Somebody help me, please? Thanks in advance.
-
How to insert text at cursor position in a web browser?Hi all, This is what I did (VC++ 6.0): 1. Add a new dialog 2. Insert ActiveX Control: Microsoft Web Browser (which added CWebBrowser2 class) 3. Add the object in the dialog 4. Create a variable for that object (CWebBrowser2 m_ctlBrowser;) Now, so far so good. I can go to the website I want. My question is: once I am in the desired website which prompts user input, I want to be able to simply press a button to fill it out. Let's say I already put the cursor there and there is only one "edit box" to fill. Is this doable? Thanks for any suggestion.
-
Copy Folder to FolderTry "Search Messages" for
FindFirstFile
in this site. There were quite a few examples. -
Copy Folder to FolderHi, Try using
FindFirstFile
andFindNextFile
to enumerate all files in Folder A, then useCopyFile
to copy each found file to Folder B. (You can useCreateDirectory
to create Folder B if it doesn't exist). -
How to pass array of byte?I knew I was missing something simple, but I do not expect it to be that simple. Thanks a lot.
-
How to pass array of byte?I am trying to pass an array of binary data from one function to another, but it fails. Why?
void C1:Caller()
{
BYTE *pTemplate = NULL; DWORD dwSize=0;
GetData(pTemplate, dwSize);
// in here dwSize=1024, which is correct
// but pTemplate is NULL! Why?
}void C1:GetData(BYTE *pTemplate, DWORD &dwSize)
{
delete pTemplate;
pTemplate = NULL;dwSize = 1024;
pTemplate = new BYTE[dwSize];
// ... fill pTemplate with desired data
}Anyone can help me here? Thanks.
-
Blank printout to printerI am NOT using Doc/View framework. The view/doc I am using are the classes from the custom control I am using (number 3 in my original post). The function that prints on the screen is
void CReportView::OnDraw(CDC* pDC)
{
CReportDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Draw(pDC);
}The pDC above is pointing to the screen, right? My thinking is that if I use the use printer's pDc, then it should print out on the printer, yes?
void CReportView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
CReportDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Draw(pDC);
CScrollView::OnPrint(pDC, pInfo);
} -
Blank printout to printerThat one doesn't have print preview, does it? My reports should be shown on the screen to the user, along with the option to print it out. So you can't locate the problem in the code? Regards, jsix
-
Blank printout to printerI use the ReportViewDlg to show the report in the custom control (see number 3 in my initial post). I think the pDC is correct. Here is the function where I inserted the DrawText that prints OK.
void CReportView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
CReportDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Draw(pDC); // This does not print anythingCRect printArea;
printArea.SetRect(0, 0, pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES));
pDC->DrawText("My Test is OK.", printArea, DT_NOPREFIX | DT_WORDBREAK); // This prints OKCScrollView::OnPrint(pDC, pInfo);
} -
Blank printout to printerAh, so you can't compile it now, I see. Could you please try it later? In Chris' article, it shows that the parameters are set from CMyDialog::Print() and pass them to the view class.
OnPrint(&dc, &Info); // Call your "Print page" function
Anyway, I tried setting/calling the print dialog from within the view, same result: empty page.
-
Blank printout to printerThanks for the tips, but actually I once trying inserting one DrawText function and it printed out the text fine, but the report was not printed. So I am guessing that the parameter for the printer were correct already and problem is somewhere else. Did you try compiling and printing my report? (I know printing is not easy. But I want to have something printed out first, correctly or not, before experimenting/learning other parameters).
-
Blank printout to printerHi, Yes, following the article number 4, I use CreaterPrinterDC and initialize m_rectDraw and m_nCurPage. I do not change the page orientation nor the MAPMODE (I figure I can deal with this later IF the printed results is incorrect, yes?) Regards, jsix
-
Blank printout to printerHi all, I am writing an MFC program (VC++ 6) that generates a report and supposedly able to print it out. The report is fine, but somehow it prints a blank page to the printer. After days of debugging the code, I still cannot locate the problem. This is why I can't simply post the problematic code here, I don't know which part is the problem! (Please forgive me if this is really not the right way to ask) Here I created a (much) simplified code that simulates my problem. It could be because: 1. It is SDI-based program, but I deleted the CDocument class since I don't need it. 2. I use Easy! Reports (http://www.codeproject.com/KB/miscctrl/easyreports.aspx[^]) to generate the report 3. The report is shown using a custom control (http://www.codeproject.com/KB/docview/dfv.aspx[^]) 4. Lastly, I am trying to print without using doc/view framework (http://www.codeproject.com/KB/printing/printing_wo_docview.aspx[^]) Could anyone please help me here. From what I understand, all I have to do is prepare the device context for printing (using number 4 above) and send it to the report generator function (number 2). Yet, it prints a blank page. If anyone could please take a glance and point me to the right direction, I would really appreciate it. Thanks. Download link: http://rs324.rapidshare.com/files/121245334/TestReport.zip[^]