|
Any tips on how to generate report using C++ programming (MFC). I have worked with visual basic before and is aware that VB has their own built in reporting tool for report generation. But im not sure how to do that using C++ language. Do I need to use Crystal Report? The report will contain info that is retrieved from the database. This report should also support the print feature. Pls help me! Tks...
Best Regards,
xiAoYJia
|
|
|
|
|
BusinessObjects provide an API for Crystal Reports. You should be able to find example C++ code on their website.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Best approach is using crystal report. You can use the Crystal report control just like in VB by adding the its OCX to your project. Crystal report object itself is capable of printing. You can pass query to your report in vc++.
|
|
|
|
|
Tks for your reply! I didnt work with Crystal Report in Visual Basic. I used their built in reporting tool instead. I would appreciate if u could provide me more details on "You can use the Crystal report control just like in VB by adding the its OCX to your project". Or do u happen to know of any good links that provide useful info?
Best Regards,
xiAoYJia
|
|
|
|
|
OK. I could send you a sample application. Just send me you email or your MSN ID so that we could chat.
Using crystal report in vc++ is just like using any other registered control or active control if we would speak in vb. All you need is to add project reference to it, then drag the control to your dialog, assign a variable name to that control, then you can access the methods to display the report as simple as m_crystalreport.setaction() after initializing it.
To make it simple, here are the steps that i followed:
1. Install Crystal report
2. Create a dialog based application.
3. Click PROJECT->ADD TO PROJECT->COMPONENTS AND CONTORLS menu.
4. Locate under registered activex control the crystal report.
5. Click OK. Some info will prompt. Just click OK
6. Back to you resource viewer. A new icon will be listed in your Control Toolbar. If you hover your mouse pointer to it, it will have a tooltip indicating a crystal report...
7. Add that to your dialog.
8. Assign a variable name to it, using class wizard. Say you name it m_crystalCtrl;
9. Back to your class browser, crystal report interface classes will be added to your project. Dont bother about that.
10. add a button to your dialog, then add event hadler to it. say button _click event.
11. Assuming that you already created a report template( connected it with your db), then you can display the report by adding the following code:
m_crystalCtrl.SetReportFileName("MyReportFilename.rpt"); // change to you report filename
m_crystalCtrl.SetWindowMaxButton(TRUE);
m_crystalCtrl.SetWindowMinButton(TRUE);
m_crystalCtrl.SetProgressDialog(FALSE);
m_crystalCtrl.SetWindowShowProgressCtls(FALSE);
m_crystalCtrl.SetWindowState(2); //Maximized
m_crystalCtrl.SetDestination(0); //To Window = 0 Printer = 1.
m_crystalCtrl.SetAction(1);
m_crystalCtrl.Reset();
|
|
|
|
|
Hi all,
I need to create Korean font using MFC CreateFont() function Below i have given the code which i tried for creating the font.But the Korean characters are not getting displayed .Can some one help me in telling whats wrong with my code??
CFont nFont;
nFont.CreateFont(0,0,10,10,400,FALSE,FALSE,FALSE,JOHAB_CHARSET ,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,FIXED_PITCH |FF_MODERN,(unsigned short *)"Batang");
CFont* pOldFont=(CFont *)pDC->SelectObject(&nFont);
pDC->TextOut(50,50,buffer);
pDC->SelectObject(&pOldFont);
I have written this code in the OnDraw() of my view class.Pls help me
Thanx in advance
Poorni
|
|
|
|
|
See this example on the GodeGuru forums. It shows you how to create Japanese text. The process is very similar for Korean text, but you use a different character set, a different face name, and different hex codes for the characters.
Follow the forum posts through one by one, and use the methods described there to discover the hex codes and stuff like that. Doctor Luz's post, where he shows an example code and the resulting character string, is a working example, as I tested them out myself as well.
Just use a different character set and a font. Also use Internet Explorer to determine what hex codes your text needs.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi...
forget abt this method to create font..
Use my method..
CFont *nFont = new CFont;
n_Font->CreatePointFont(200, "Batang");
CFont* pOldFont=(CFont *)pDC->SelectObject(&nFont);
pDC->TextOut(50,50,buffer);
pDC->SelectObject(&pOldFont);
I think it would work fine..also this font must be present in your system..
OK! Good bye..
|
|
|
|
|
hi,
Thanx for ur reply no the code u have given is also not working..Still the program is displaying junk characters only............Is something that i have left out in my code?????Do help me
|
|
|
|
|
HI its giving error at this line......The runtime error states that The memory location referred cannot be read.............Any ides y such error happens?????
VERIFY(nFont->CreatePointFont(200, L"Batang"));
|
|
|
|
|
Hi,
I'd like to add a maximize button to my property sheet and the following code does it. However, it also adds a minimize button which I do not want. The mimimize button is disabled but I would prefer to remove it completely. How can I remove it?
<br />
int MyPropertySheet::OnCreate(LPCREATESTRUCT lpCreateStruct)<br />
{<br />
if (CPropertySheet::OnCreate(lpCreateStruct) == -1)<br />
return -1;<br />
<br />
SetWindowLong(this->m_hWnd, GWL_STYLE, GetWindowLong(this->m_hWnd, GWL_STYLE) | WS_MAXIMIZEBOX);<br />
<br />
return 0;<br />
}<br />
|
|
|
|
|
Hi,
I want to find out whether some application is trying to access the network resource like internet (HTTP,SMTP POP,FTP etc etc. –any sort of network resource usage) or any other network resource like mapped drives,VPN etc.
I want to capture this .
Secondly I want to determine which application is trying to access that resource.
Regards
Tarun
Blue Pill or Red Pill........??
|
|
|
|
|
WinPCap[^] can help you capture the network traffic.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Hi, You might want to try Windows hooks for capturing network usage on individual application basis. Try detours library from Microsoft research http://research.microsoft.com/sn/detours/. Also if you are not very much familiar with hooks, then refer to articles on codeproject. http://www.codeproject.com/system/hooksys.asp.
Mayank Goyal
|
|
|
|
|
Hi out there...
I'm struggeling with the following question:
What is the better way to do painting?
- Have a WorkerThread that prepares data and an OnTimer handler that displays the data if modified
or
- Having a WorkerThread that holds a handle to a DC (or maybe memDC) that paints to the window whenever he thinks its due.
I'm trying to optimize my applications performance and lower the CPU usage. Maybe there are even more alternatives on how to do painting.
Which approach do you use ?
Regards,
Daniel
|
|
|
|
|
Danoo wrote:
- Have a WorkerThread that prepares data and an OnTimer handler that displays the data if modified
Sure, you can have a worker thread preparing data. The OnTimer() should be in the GUI thread, though. You must however, of course, correctly synchronize access to shared data.
Danoo wrote:
- Having a WorkerThread that holds a handle to a DC (or maybe memDC) that paints to the window whenever he thinks its due.
If you keep a DC and use it to paint in, then it's not a worker thread in my point of view, but a GUI thread. A memory DC might pass as appropriate in some extreme cases. But don't use multiple GUI threads. Just don't.
Before you think about any other alternative - are you following the #1 rule of optimization?
Dont't optimize until you have actually measured that it's necessary!
Just lowering the CPU usage is not a justified reason to optimize. Is the CPU usage too high? That's the question.
Danoo wrote:
Which approach do you use ?
Given the fact that I must optimize, I tend to stick to one thread only, unless the amount of number crunching required to update the GUI is massive.
I would probably use a class or private DC, since they exist for that particular purpose. When the timer fires, I would invalidate only changed areas and paint what I'd prepared between the timer events.
--
Dad, how strange it is that the pig can speak. *thoughtful pause* It must have lost its "oink". (my 3-year old daughter Moa, while watching Babe)
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. (Douglas Adams)
|
|
|
|
|
A combination of both, I believe. If I was doing this, I'd go for the timer function, with an user option to set the refresh rate.
Also, when using the timer approach, you should have a memory DC in the worker thread, draw all data in this thread, and then just use the timer to BitBLT the data from the memory DC into the window's client area. This optimizes graphic card usage, as no data is drawn during the actual 'creation' of the display. Naturally, the worker thread needs a way to tell the timer if the new data is ready to be displayed, or if the thread is still drawing it.
Consider an option that if the window that shows the results is not a top-level window or doesn't have focus (is minimized, for example), then no drawing takes place. This would optimize the CPU usage even more if the user is doing something else meanwhile.
Moreover, if your application requires real-time results display, then the best option is to use DirectX APIs for your display. Unfortunately I cannot provide any examples.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I'm sure this is something simple that I just can't find.
I am adding a list of disk drives to a combo box. I used GetLogicalDriveStrings for the list of drives and GetVolumeInformation to get the volume name. I take the volume name and combine it with the drive name so it looks just like the drive tree in explorer. My problem is when a volume does not have a label. When a volume does not have a label, Explorer substitutes a generic string like Local Disk, DVD Drive, DVD/CD-RW. Where does it get these strings? GetDriveType doesn't even have a DVD constant added yet. I don't even know what to look for on MSDN, but everything I have tried have not produced any results. Any help is appreciated!!
|
|
|
|
|
This just a guess, but it might be from the registry.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\D\DefaultLabel
changes the description in Explorer for my CD-ROM drive when there's no disk in the drive. Note the drive letter in the registry key, so you'll need to change that for other drives.
|
|
|
|
|
Graham Bradshaw wrote:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\D\DefaultLabel
What version of windows are you using? I'm using XP Home and that key does not exist. I tried searching for DriveIcons and DefaultLabel. Thanks for trying!
|
|
|
|
|
Pheonix wrote:
What version of windows are you using?
XP Professional SP1. You may have to add the key - I also have an entry for the E: drive, which is a Memory Stick (the computer is a Sony VAIO laptop).
|
|
|
|
|
I guess the home edition of XP just doesn't contain this key. It's good to know that I can put anything I want in there though. I'm trying to find the windows defaults that explorer uses. I'll keep searching. Thanks for the help!
|
|
|
|
|
Update: Just tried it here, and it works with a ZIP drive as well. The key quoted is the whole key. If you set the default entry for that key to a string, Explorer picks that up and uses it instead when displaying the drive.
|
|
|
|
|
Hi all,
I am a new to MFC/VC++.
I have already asked my question,but I think,experts are unable to understand my question.Once again I would like to explain my question.
I create a property sheet which contains three property pages.
pag1.
pag2.
pag3.
page1 contains three - Text Box.
text1,
text2,
text3
Now, I create thee- member- variable of int type.like
m_ntxt1,
m_ntex2 and m_ntxt3,
I enter two integer value in tex1 and text2.
Finally,When I click 'OK' button on a propety sheet(not on a propery page).It should be displayed the sum of integers(m_ntxt1+m_tex2) in text3 and AfxMessageBox.How to do this.
Thanks
rajesh
|
|
|
|
|
The following is a useful check-up list to accomplish what you describe
1. Create a command handler for the property sheet's OK-button click.
2. In this handler, use GetActivePage to get a pointer to the currently active property page object.
3. Use DYNAMIC_DOWNCAST to cast from the CPropertyPage pointer returned above into your derived class' pointer.
4. Create a function into your derived class that does the following:
4.a. Calls UpdateData(TRUE)
4.b. Calculates m_ntxt3 = m_ntxt1 + m_ntxt2
4.c. Calls UpdateData(FALSE)
5. Now, in the property sheet's command handler, call the derived property page class' function that will calculate the sum.
This approach requires that all the controls (Edit boxes) and the integer variables belong to the derived property page class. If you need to display a pop-up message box, then use a temporary CString object, formatting it with the integer data (CString::Format ), then calling AfxMessageBox and supplying the CString object as the text parameter.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|