|
hello
I need to make a program that is supposed to export data to a table like structure.I am coding in vc++ 6.0
Is there some way to dump all the data resulted from a program to a excel table or something
also, I have some experiences with list boxes in c, is there any way to make a list box have 2 collumns instead of just one or does this simply require 2 listboxes placed one next to another.
Is there another structrre besides the li9st box that I could use to display the resulting data in a table like form.
Any other suggestions about how a program like this might best be designed are also wellcomed. thank you
pLesae reply.
|
|
|
|
|
Spiritofamerica wrote:
Is there some way to dump all the data resulted from a program to a excel table or something
The easiest way is to write your data to a *.csv (comma seperated values) file. *.csv files are simple text files that are easy to create and are supported by most database and spread sheet programs out there.
Spiritofamerica wrote:
is there any way to make a list box have 2 collumns instead of just one
List boxes can be created with the LBS_MULTICOLUMN style, but I have never used a listbox that way. I use a ListView control instead when I want multiple columns.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
To use Excel function in VC++, you should first import Excel typelib From your office location and than use the code like:
CoInitialize(NULL); // Init COM
CLSIDFromProgID(L"Excel.Application",&clsid);
_Application ExcelApp; //Construct Excel object
if (FAILED(GetActiveObject(clsid, NULL, (IUnknown**)&pUnk)))
{
if (!ExcelApp.CreateDispatch("Excel.Application"))
{
AfxMessageBox("Failed to create Excel object!");
}
}
else
{
hr=pUnk->QueryInterface(IID_IDispatch, (void**)&pDispExcel);
ExcelApp.AttachDispatch(pDispExcel);
}
// and ...
See MSDN for detail reference.
Lisoft
|
|
|
|
|
If you use dialog display data , you can add List Control(not List Box) to the dialog.
|
|
|
|
|
Hi, Friend,
I have a edit control in a dialog. I initialize it to "Type Here". I also want to select "Type Here", and make it highlight.
I do this
//output text
m_ctlEdit->SetWindowText("Type Here");
//select all text
m_ctlEdit->SetSel(0,-1);
all works fine. but the "Type Here" won't highlight. I study CEdit, I could not find any method to highlight selected text.
Thank you
|
|
|
|
|
Is this[^] the effect you are after?
As for selecting the text, it works better if you place the SetSel(0, -1) code in the edit control's EN_SETFOCUS notification message handler.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Howdy all,
First off this board is great, thanks for everyone who helped me earlier.
I'm explicitly loading a DLL and constructing an object of type CTestDLL. In this class's constructor is the following code:
CTestDLL::CTestDLL()
{
fstream outfile;
cerr << "constructed";
outfile.open("c:\test.log", ios::app);
if (!outfile)
{
cerr << "could not open file";
exit(1);
}
}
It always fails to open, but the constructor's definitely being called. In addition to failing to open, I always get "the instruction at 0x00000000 referenced memory at 0x00000000. The memory could not be read".
I've tried creating the file manually, then trying to open it, with no luck. I've tried casting the const char* to a (LPCTSTR), using a CString, making the whole class visible, or just the individual methods (constructor/destructor) visible, all with the same results and same error.
Any ideas? I've googled and found others with the same problem, but unfortunately no answers. If I take the fstream code out the object contructs fine, but the fstream seems to muck things up.
|
|
|
|
|
change "c:\test.log" to "c:\\test.log"
must have double '\'
|
|
|
|
|
Thank you so much, what a silly mistake! What's weird is it fails even if I say "test.log" -- for some reason I have to state the drive.
|
|
|
|
|
Hi all:
Recently I've been reading Charles Petzold's Programming Windows, but in the The GDI Mapping Mode chapter I encounter a few sentences for which I think they're contradict with each other. I'm sure It just because I'm just don't fully understand the priciple in it. But, for now it really confused me. So I hope if someone had readed this book or have a understanding about Mapping Mode can show me the way! The following is the excerpt for the book that confused me!
*********************************************************
Here's how the functions work: If you change the viewport origin to (xViewOrg, yViewOrg), the logical point (0, 0) will be mapped to the device point (xViewOrg, yViewOrg). If you change the window origin to (xWinOrg, yWinOrg), the logical point (xWinOrg, yWinOrg) will be mapped to the device point (0, 0), which is the upper left corner. Regardless of any changes you make to the window and viewport origins, the device point (0, 0) is always the upper left corner of the client area.
For instance, suppose your client area is cxClient pixels wide and cyClient pixels high. If you want to define the logical point (0, 0) to be the center of the client area, you can do so by calling
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;
The arguments to SetViewportOrgEx are always in terms of device units. The logical point (0, 0) will now be mapped to the device point (cxClient / 2, cyClient / 2). Now you can use your client area as if it had the coordinate system shown below.
00-y0|
00000|
0-----|----+x
00-x0|
00000|+y
(the origin shifted to the center, sorry for the zero because without them the coordinate will not be look like coordinate)
The logical x-axis ranges from -cxClient/2 to +cxClient/2, and the logical y-axis ranges from -cyClient/2 to +cyClient/2. The lower right corner of the client area is the logical point (cxClient/2, cyClient/2). If you want to display text starting at the upper left corner of the client area, which is the device point (0, 0), you need to use negative coordinates:
TextOut (hdc, -cxClient / 2, -cyClient / 2, "Hello", 5) ;
You can achieve the same result with SetWindowOrgEx as you did when you used SetViewportOrgEx:
SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ; //ok know problem, the (-cxClient / 2, -cyClient / 2) is changed to the device point (0,0), I understand that
The arguments to SetWindowOrgEx are always in terms of logical units. After this call, the logical point (-cxClient / 2, -cyClient / 2) is mapped to the device point (0, 0), the upper left corner of the client area.
What you probably don't want to do (unless you know what's going to happen) is to use both function calls together:
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;
SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ;
//from what I'm understanding, after the logical point (0,0) mapped to veiwport center the SetWindowOrgEx (...) will make the point already in the upper left corner mapped to the device point (0,0) which is also at left corner (0,0)
This means that the logical point (-cxClient/2, -cyClient/2) is mapped to the device point (cxClient/2, cyClient/2), giving you a coordinate system that looks like this:
00000000000000-y|
0000000000000000|
00000000000-x-----|
(the origin shifted to the lower right corner, but I think it should be at the upper left corner, why why why?)
I don't know how's the origin shifted to lower right corner. given that If you change the window origin to (xWinOrg, yWinOrg), the logical point (xWinOrg, yWinOrg) will be mapped to the device point (0, 0)
I think the origin will shifted to the upper left corner.
Beside if you change the window origin to (xWinOrg, yWinOrg), the logical point (xWinOrg, yWinOrg) will be mapped to the device point (0, 0), then I think It will be no matters regarding how you specify you window origin because It always be shifted to device point (0,0) which is upper left corner and it contradict with the second picture.
|
|
|
|
|
The easiest way to make sense of these type of things is to see them in action. So make a simple SDI test app and insert the follow code in the OnDraw function
void CSDITestView::OnDraw(CDC *pDC)
{
CSDITestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->SetViewportOrg(50, 50);
pDC->SetWindowOrg(50, 50);
pDC->Rectangle(0, 0, 100, 100);
} Now play with the code. Comment out the SetViewportOrg and SetWindowOrg lines, change the values passed to them, etc and run the program to see what happens. You will notice that the rectangle, which you are suppose to be drawing at location 0, 0 will be drawn at different locations depending on the values passed to the Set* functions.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I have written a program in C++. When I run the program it gives me an exe file. I would like to know what code I can enter which would give the user the option to print the output. Forward slashes represent the code I entered. I get many errors with this code. If you need the rest of the programs code to assist me let me know and I will send it.
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
using std::cout;
using std::cin;
using std::fixed;
using namespace std;
//#include
int main() //(int,char*)
//{
//ofstream printer ("1pt1:");
//Printer <<"test"<
|
|
|
|
|
BRIMID wrote:
//ofstream printer ("1pt1:");
//Printer <<"test"<<endl;
return="" o;<="" i="">
The first letter in "lpt1" is a lower case 'L' not a one. C++ is case sensitive in variable names: printer vs Printer. main() has to return an integer 0 (zero) not the letter 'o'.
ps. when posting code your include files are being dropped. What you should do is click on the "Do not treat <'s as HTML tags" check box that is located immediately below the text edit window used to enter messages.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
This is the code and it does not work. I am getting 5 error messages when compiling. If someone could give me assistance from //#include to //{ I would appreciate it. Do I have the function in the right place? That sort of thing. You guys have really been helpful.
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
using std::cout;
using std::cin;
using std::fixed;
using namespace std;
//#include
int main() //(int,char*)
//{
//ofstream printer ("lpt1:");
//Printer <<"test"<<endl;
// return 0;
//}
{
int c;
double fee;
double total;
char a ='y', ans;
string input;
int number;
Thanks
|
|
|
|
|
i want to develop an exe (by VC++) which contains icons of 256 colors, how to do that? is it possible?
includeh10
|
|
|
|
|
Yes, it is possible. But if you want to edit icons with any more than the basic 16 colours you have to use another graphic editor, not the one supplied with visual studio. Create your icon in the other editor and then import it into your project.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
hi there
i have a big problem with RasSetEntryProperties() function
i fill the RASENTRY obj correctly but it returns error 632
(means : structure size incorrect)
I searched all the the web but nothing found
any idea please
I append the cope here :
rasEntry.dwSize = sizeof (RASENTRY);
ras_result= rasObj.RasSetEntryProperties (NULL, strName, &rasEntry,sizeof(RASENTRY), NULL, NULL) ;
if (ras_result)
{
TRACE ("RasSetEntryProperties failed %s\n", strName);
return FALSE;
}
|
|
|
|
|
I'm not sure this is the best category to ask this question.
I'm trying to develop a plugin/add-on for Yahoo Messenger that would combine most of the functions offered by current plugins.
Does anyone have any experience or know of any resources I could use?
Thanks
|
|
|
|
|
Nice day, programmer !
would you be so kind to help me on with a non-ordinary problem I've got... ??? I assume you've had one in your practice.
I wanna make a smoothscroll of CListBox (with child buttons) using standard scroll bar which is usually embedded into every
Common control you know.
Problem: in the smoothscrolling transition process I get a copy of the child window (button) at the different coords... and
then this copy will move with the original button together, but at the bottom of that.
I had traced that process and got the following:
1. Create CListBox
2. Insert items and buttons into the control
3. Debug every WM_MOVE messages which come for every button from the ScrollWindowEx which is called (i suppose) at superwnd
function of the original 'LISTBOX' window class. (you know that ScrollWindowEx (with smoothscroll enabled) divide the
scrolling process by moving ticks)
4. For the 1st tick: a copy of the original button had been drawn by something after I had continued the debug process from
the WM_MOVE point.
5. For the 2nd tick: i tried to correct the code with pParent->RedrawWindow() and this->RedrawWindow(). it had been working
well until I didn't pass the execution to windows framework. The next tick came with the same artifact, which was being
moved with the original button...
6. So, i had got a button scrolled with 10 ticks and the copy at the bottom of the original one...
Partitially i have solved that problem. I put SetRedraw(0) for a button before the original WM_VSCROLL CListbox's handler
and then restored with SetRedraw(1) at the WM_MOVE button's handler. This worked well but a button was flickering when I
scrolled CListBox... Following that way I also need to handle every PG_UP, PG_DOWN and MOUSE_WHEEL event and correct with
the same code... But if I wanna scroll CListBox with the mouse cursor, dragging it up/down ???
Please, help me to solve this problem.
mailto: onelse@yahoo.com
I would be grateful for any respone.
Thank you.
Nalik
|
|
|
|
|
this is post i found in CodeGuru forum
1--------------------------------
Well, if the UpdateResource is not working for you, do this:
Open the file that contains the resource - CreateFile.
Create a file mapping of that file - CreateFileMapping.
Create a view of the file - MapViewOfFile.
Find the resource in the view using the pointer acquired in the previous step in place of HMODULE - FindResource.
Load the resource - LoadResource.
Lock the resource - LockResource.
Write the new resource to the address retrieved in the previous step. Make sure the new resource has the same size as the old one.
Unmap the view - UnmapViewOfFile.
Close file mapping - CloseHandle.
Close the file - CloseHandle.
2--------------------------------------
You have a new resource in memory. I trust you have the address of it, since you attempted to use UpdateResource.
The new resource is the same type and the same size as the one you are replacing. The size issue is very important. If it is larger, it may corrupt the file you are writing to. You can use SizeOfResource to verify.
Now, in previous steps you loaded a file into memory. In step 6 you recieved a pointer to the first byte of the resource you are about to replace. You can now use the function memcpy to copy the new resource into the memory occupied by the old resource. Calling UnmapViewOfFile wil save this change to the file.
One last thing. Check return values of every function you call for failure. Writing to an executable file is not something to be taken carelessly.
---------------------------------------------
it sounds terrible.
do u think the replies are reght?
any comments??
thx
includeh10
|
|
|
|
|
i need examples of using UpdateResource() to update icon of an exe file from an icon file.
thx
includeh10
|
|
|
|
|
Hello everyone,
I am having trouble changing focus from child window to another. Of course, I want to be able to do that without using the mouse or keyboard, but the code itself. The application is used in an automated video grabbing.
This is the code I have written:
class CMyAppDoc : public CDocument
{
public:
CView *pOldActiveView;
..
..
CMyAppDoc::OnButton1()
{
CMDIFrameWnd* pMainWnd = (CMDIFrameWnd*)AfxGetMainWnd();
// Get the active MDI child window.
CMDIChildWnd* pChild = (CMDIChildWnd*)pMainWnd->MDIGetActive();
// Get the active view attached to the active MDI child window.
pOldActiveView = pChild->GetActiveView();
}
After clicking Button1 I manually change the focus by the mouse and then click Button2, which includes the following code:
CMyAppDoc::Button2()
{
pOldActiveView->SetActiveWindow();
}
Summarizing the code, clicking the Button1 should assign the pointer pOldActiveView the address of the active child window during the time it is pressed. Then After manually chainging the focus to another child window the active child window will change but the pointer is still pointing to our old active child window. So then by clicking Button2 should set the focus on the old child window, but unfortunately nothing changes.
I have also tried "pOldActiveView->SetFocus()" instead but didn't change anything as well.
Any help will be highly appreciated.
|
|
|
|
|
I declared a public variable on MainFrm.h called int m_enableD.
I use #include "MainFrm.h" in my ProgramView.cpp but when I compiled it, it says "error C2065: m_enableD : undeclared identifier".
Did I miss something? I usually did the same way and it works.
Thanks.
|
|
|
|
|
The error can be the way you use the m_enableD variable.
Otherwise there is no problem...
|
|
|
|
|
I use it like
if(m_enableD = 0) {
statement
}
is it ok? thanks
|
|
|
|
|