|
* Bold indicates new messages since 10:25 16 Feb '09
|
C++ / MFC
Home >
Forums >
C++ / MFC
| | Msgs 1 to 25 of 8,693 (Total in Forum: 378,903) (Refresh) | FirstPrevNext |
|
 |
 | How to get an answer to your question |  | Chris Maunder | 18:19 12 Feb '09 |
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- If you are posting source code with your question, place it inside <pre></pre> tags, or click the "Ignore HTML tags in this message" check box.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers, Chris Maunder CodeProject.com : C++ MVP
|
|
|
|
 |
|
 |
Hello,
We would like to print some simple drawing output using GDI. We have used the PrintDlgEx function to obtain a device context handle to a printer, but are unsure of how to proceed. We have not been able to find much example code and are a little stuck.
Basically, we have the DC handle. Presumably we then call Rectangle(x,x,x,x) etc to do the painting. What must be done then to initiate the actual printing?
Any help would be appreciated.
Thanks,
Steve
|
|
|
|
 |
 | How to compile a native (ie. using NT API instead of Win32) x64 app ? |  | Defenestration | 1 hr 35mins ago |
|
 |
I'm trying to compile the SysInternals Native app[^] for XP x64 (and other Windows x64 ), so I can create an app which can run during boot-time (similar to chkdsk), but am not having much luck. As SysInternals have stopped supplying native.xip, you can get it from
http://www.dowers.net:8080/ftp/Programs/InsideWin2000/Sysinternals-Website/NATIVE.ZIP[^]
I've installed the Windows Server 2003 DDK, and have started a Windows Server 2003 Free x64 Build environment (using the shortcut). I've then copied all the Native sources and makefile to ddk\inc, as instructed to do so at the bottom of the linked article. However, when I run build.exe, I get two identical errors:
C:\WINDDK\3790~1.183\inc>build BUILD: Adding /Y to COPYCMD so xcopy ops won't hang. BUILD: Using 4 child processes BUILD: Object root set to: ==> objfre_wnet_AMD64 BUILD: Compile and Link for AMD64 BUILD: Computing Include file dependencies: BUILD: Examining c:\winddk\3790~1.183\inc directory for files to compile. c:\winddk\3790~1.183\inc - 1 source files (82 lines) BUILD: Saving C:\WINDDK\3790~1.183\build.dat... BUILD: Compiling (NoSync) c:\winddk\3790~1.183\inc directory 1>errors in directory c:\winddk\3790~1.183\inc 1>c:\winddk\3790~1.183\bin\makefile.new(1106) : error U1050: Setting TARGETPATH= C:\WINDDK\3790~1.183\lib in .\sources is not valid - please use obj. BUILD: nmake.exe /nologo BUILDMSG=Stop. -i NTTEST= UMTEST= NOLINK=1 NOPASS0=1 PA SS1_NOLIB=1 AMD64=1 failed - rc = 2 BUILD: Compiling c:\winddk\3790~1.183\inc directory 100>c:\winddk\3790~1.183\bin\makefile.new(1106) : error U1050: Setting TARGETPAT H= C:\WINDDK\3790~1.183\lib in .\sources is not valid - please use obj. BUILD: nmake.exe failed - rc = 2 BUILD: Compile errors: not linking c:\winddk\3790~1.183\inc directory BUILD: Done
0 files compiled - 2 Errors
What exactly does the error mean ?
1>c:\winddk\3790~1.183\bin\makefile.new(1106) : error U1050: Setting TARGETPATH= C:\WINDDK\3790~1.183\lib in .\sources is not valid - please use obj.
How can I fix it ?
Is there any good information on how to correctly setup a build environment for building native apps for both x86 and x64 ?
|
|
|
|
 |
|
 |
Hi. I'm new in c/c++... and I'm a little confused... I made a dll in c/c++ (using some example I saw on-line), and now I want to load it in a new project, but it doesn't work. I paste the dll file in the project debug folder, and I'm using HINSTANCE myDll = LoadLibrary((LPCWSTR)"TestingDll.dll");
to access to it, but myDll is always empty...Can anyone tell me what possible I'm doing wrong? Thanks
|
|
|
|
 |
|
 |
All the various dlls that TestingDll.dll is dependent on wuould not be present. Check out the dependencies of TestingDll.dll using depends.exe and paste all those dlls also in the same folder.
|
|
|
|
 |
|
 |
Thanks for your atention... At the beginning I thought that was the problem and decided to do something very basic for testings, but I still can not access to it. For my testings I made:
//MyDll.cpp #include "MyDll.h" namespace Functions{ Person MyFunctions::first() { struct Person myPerson; myPerson.name = "asd"; myPerson.age = 123; return myPerson; } }
//MyDll.h namespace Functions{ struct Person { char *name; int age; }; class MyFunctions { public: static __declspec(dllexport) Person first(); }; }
Then the DLL file I paste in the new project folder (only this one, because for my point of view I don't need nothing more, because it is very simple and doesn't use/depend nothing more ), right?
In the new project I made:
#include "stdafx.h" #include "windows.h" using namespace System;
int main(array<System::String ^> ^args){ HINSTANCE myDll = LoadLibrary((LPCWSTR)"TestingDll.dll"); if(myDll) { Console::WriteLine("DLL loaded \n"); } else { Console::WriteLine("DLL failed to load \n"); } return 0; }
And the result always is -> "DLL failed to load".
It doesn't returns any error, but doesn't do what I want . I apologize, but due to my inexperience I did not understand the problem that could cause this ( for sure is something that I'm doing wrong, or forget). Can you help me?
|
|
|
|
 |
|
 |
From LoadLibrary documentation [^].
Return Value
If the function succeeds, the return value is a handle to the module.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
BTW possibly you should put the DLL inside the project folder.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]
|
|
|
|
 |
|
 |
Thanks for your atention... I already have the DLL inside the new project folder, but it still not work and I couldn't understand what could be the cause of this, because it doesn't return any error...
|
|
|
|
 |
|
 |
As stated by the documentation I linked in my previous post, if the LoadLibrary return HANDLE is NULL then you have to call GetLastError in order to get some understanding of what's happening.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]
|
|
|
|
 |
 | Convert const string& to CByteArray ? |  | mayur8u | 3hrs 58mins ago |
|
 |
Hi,
How do i convert a const string& to CByteArray ?
I have to convert the string to CByteArray and pass the member functions GetData() and GetSize() to a method as parameters
Is it possible or is there an alternative way of converting string to CByteArray.
An example would be appreciated.
Thanks in advance,
Regards, Mayur M
|
|
|
|
 |
|
 |
Try (I didn't test it...)
CString str = _T("Hi"); CByteArray arr; int iSize = (str.GetLength()+1) * sizeof(TCHAR) const BYTE * pByte = (const BYTE *) (LPCTSTR) str; for (i = 0; i < iSize; i++) { arr.Add(pByte[i]); }
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]
|
|
|
|
 |
|
 |
Thanks for your reply.
The code snippet works fine. But the snippet is for convertion of CString to CByteArray. But i'm looking for a const string conversion to CByteArray.
Even if i use the CString conversion to CByteArray, is there any inbuilt methods rather than using the for loop.
Regards, Mayur M
|
|
|
|
 |
 | need a minor help in my program [modified] |  | tksrules | 5hrs 5mins ago |
|
 |
I have a code written as:- #include #include #include
using namespace std;
// This class Package is the base class for two other classes, TwoDayPackage and OverNightPackage.//
class Package // begins class Package { public: Package(const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, double = 0.0, double = 0.0); // constructor
// set and get functions for sender void setSendName(const string &); string getSendName() const;
void setSendAdd(const string &); string getSendAdd() const;
void setSendCity(const string &); string getSendCity() const;
void setSendSt(const string &); string getSendSt() const;
void setSendZip(const string &); string getSendZip() const;
// set and get functions for recipient void setRecName(const string &); string getRecName() const;
void setRecAdd(const string &); string getRecAdd() const;
void setRecipientCity(const string &); string getRecipientCity() const;
void setRecSt(const string &); string getRecSt() const;
void setRecZip(const string &); string getRecZip() const;
void setWt(double); double getWt() const; void setShip(double); double Package::getShip() const { return shipCost; }
double Package::CalCost() const {
return (wt*shipCost); }
private: string sendName; string sendAdd; string sendCity; string sendState; string sendZip; string recName; string recAdd; string recCity; string recState; string recZip; double wt; double shipCost; }; Package::Package(const string &sname;, const string &saddress;, const string &scity;, const string &sstate;, const string &szipcode;, const string &rname;, const string &raddress;, const string &rcity;, const string &rstate;, const string &rzipcode;, double wt, double shipCost) { sendName = sname; sendAdd = saddress; sendCity = scity; sendState = sstate; sendZip = szipcode; recName = rname; recAdd = raddress; recCity = rcity; recState = rstate; recZip = rzipcode; setWt(wt); setShip(shipCost); }
void Package::setSendName(const string &sname;) { sendName = sname; }
string Package::getSendName() const { return sendName; }
void Package::setSendAdd(const string &saddress;) { sendAdd = saddress; }
string Package::getSendAdd() const { return sendAdd; } void Package::setSendCity(const string &scity;) { sendCity = scity; }
string Package::getSendCity() const { return sendCity; }
void Package::setSendSt(const string &sstate;) { sendState = sstate; }
string Package::getSendSt() const { return sendState; }
void Package::setSendZip(const string &szipcode;) { sendZip = szipcode; }
string Package::getSendZip() const { return sendZip; }
void Package::setRecName(const string &rname;) { recName = rname; }
string Package::getRecName() const { return recName; }
void Package::setRecAdd(const string &raddress;) { recAdd = raddress; }
string Package::getRecAdd() const { return recAdd; }
void Package::setRecipientCity(const string &rcity;) { recCity = rcity; }
string Package::getRecipientCity() const { return recCity; }
void Package::setRecSt(const string &rstate;) { recState = rstate; }
string Package::getRecSt() const { return recState; } void Package::setRecZip(const string &rzipcode;) { recZip = rzipcode; }
string Package::getRecZip() const { return recZip; }
void Package::setWt(double wt) { wt = (wt < 0.0 ) ? 0.0 : wt; } double Package::getWt() const { return wt; } void Package::setShip(double shipCost) { shipCost = ( shipCost < 0.0) ? 0.0 : shipCost; }
// This class TwoDayPackage is the first derived class from class Package.//
class TDP : public Package { public: TDP(const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, double = 0.0, double = 0.0, double = 0.0); // constructor
void setFlatFee(double); double getFlatFee() const; double CalCost() const;
private: double flatFee; };
// This class OverNightPackage is the second derived class from class Package.//
class ONP : public Package { public:
ONP(const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, const string &, double=0.0, double=0.0, double=0.0); // constructor
void setFee(double); double getFee() const; double CalCost() const;
private: double fee; };
// This is the test program.//
int main() { ONP box("name", "123 this Street", "boston", "ma", "12345", "receiver", "123 that street", "medford", "ma", "25341", 10.00, 1.50, .85);
TDP parcel("name2", "123 1st Street", "orlando", "fl", "56474", "receiver2", "833 2nd Street", "miami", "fl", "88472", 15.00, 1.05, 5.00);
cout << fixed << setprecision(2);
cout << "To ship a box with overnight delivery\n"; cout << "The sender " << box.getSendName()<< "\n"; cout << " " << box.getSendAdd() << "\n"; cout << " " << box.getSendCity() << " " << box.getSendSt() << " " << box.getSendZip() << "\n";
cout << "The recipient " << box.getRecName()<< "\n"; cout << " " << box.getRecAdd() << "\n"; cout << " " << box.getRecipientCity() << " " << box.getRecSt() << " " << box.getRecZip() << "\n"; cout << "The cost is $ " <<box.CalCost() << "\n";
cout << "\n\n";
cout << "To ship a parcel with 2 day delivery\n"; cout << "The sender " << parcel.getSendName()<< "\n"; cout << " " << parcel.getSendAdd() << "\n"; cout << " " << parcel.getSendCity() << " " << parcel.getSendSt() << " " << parcel.getSendZip() << "\n";
cout << "The recipient " << parcel.getRecName()<< "\n"; cout << " " << parcel.getRecAdd() << "\n"; cout << " " << parcel.getRecipientCity() << " " << parcel.getRecSt() << " " << parcel.getRecZip() << "\n"; cout << "The cost is $ "<<parcel.CalCost() << "\n";
system("pause"); return 0; }
The calcost function needs some change as it is the source of error.Somebody help.
modified on Monday, February 16, 2009 12:15 PM
|
|
|
|
 |
|
 |
Keep your question concise! No-one will want to read all of that to answer your question!
Regards, --Perspx
"A refund for defective software might be nice, except it would bankrupt the entire software industry in the first year." -Andrew Tanenbaum
"Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer." -Fred Brooks
|
|
|
|
 |
|
 |
Didn't this come out of Deitel's "C++: How to Program" book? Is this your assignment?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
 |
|
 |
yes but it is from exercise.Can you tell me where solutions are available.it would help me a lot
|
|
|
|
 |
|
 |
tksrules wrote: Can you tell me where solutions are available.
In the classroom/lab. Does the instructor offer a Q&A; session either at the start or near the end of class?
tksrules wrote: it would help me a lot
Quite the opposite, actually. You can't post a big wad of code on some Internet forum and ask someone to help you figure it out. I guess you can, but then you haven't been helped. At a minimum, you need to isolate the problem down to a small handful of statements (the actual number varies, but if it's more than a dozen, that's likely too many). Everything else is irrelevant and only acts as a hinderance.
Instead of trying to work through 200 lines of code, why not start with a smaller project, get it working, and then add to it until the problem shows itself?
This forum is frequented by a lot of sharp people that will gladly help you, but they aren't going to do it for you. You might look real closely at Package::setWt() and Package::setShip().
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
 |
|
 |
i am solving assignment myself...i will take ur advice.
|
|
|
|
 |
 | encryption and description functions in C++ on sunOS [modified] |  | suresh_r | 7hrs 39mins ago |
|
 |
hi all, if any body having the code regading encryption and decryption functions that will work in the sunOS please send it to me.
regatrds suresh
modified on Monday, February 16, 2009 7:59 AM
|
|
|
|
 |
|
 |
Do you know about Google [^]?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]
|
|
|
|
 |
|
 |
Hello All,
Iam using CTreeCtrl method to add items in a tree.Actually i create two root nodes using GetRootNode()method.I add both root nodes properly in the tree,But what's my problem is i need to add child nodes in appropriate parent(root)nodes at runtime.But,all the child nodes adding in the first parent(root)node only.once i use deleteallitems()method and redraw the tree only child nodes are added in appropriate parent(root)nodes.Without using DeleteAllItems() i need to add the child nodes in a appropriate parent(root)node. please anybody help me.
Thanks in advance,
Regards, bhanu.
|
|
|
|
 |
|
 |
I'm not really sure what your problem is...
Try this:
CTreeCtrl *pTree = (CTreeCtrl *)GetDlgItem (IDC_MYTREE);
// Add two root items HTREEITEM hRootOne = pTree->InsertItem ("Root One", TVI_ROOT); HTREEITEM hRootTwo = pTree->InsertItem ("Root Two", TVI_ROOT);
// Add one child to first root item pTree->InsertItem ("Child One", hRootOne);
// Add two children to second root item pTree->InsertItem ("Child Alpha", hRootTwo); pTree->InsertItem ("Child Beta", hRootTwo);
Note the use of TVI_ROOT for the root items, and that I keep track of the return values to use later.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
 |
 | Setting Font with Rich Edit |  | ForNow | 8hrs 9mins ago |
|
 |
Hi,
I am using a MULTILINE Edit Class with Rich Edit
It Seems like EM_SETCHARFORMAT doesn't have enough flexibility
in setting the Font
Get use the Device Contexts API's to Set the Font
hfont = CreateFontIndrect(&logfont;);
... SelectObject(hdc,hfont);
|
|
|
|
 |
|
 |
You don't set a font of a control by getting a temporary HDC and setting the font of that. At best you're wasting your time - at worst your corrupting the DC pool.
Have a look at http://www.codeproject.com/KB/edit/rulerricheditctrl.aspx[^]. Good article on rich edit stuff, with formatting buttons, etc.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
 |
|
 |
Hi,
The Main Focus of the this article is the CFontDialog CLass
Which seems like interface for Rich Edit Which uses The Charformat
sturcture Using some of the info from the LogFont structure
My real need was to able to put a certin amount of caracters on a line
of a Multiedit Dialog Box
The Logfont Structure Contains lfHeight and lfWidth data memebers
to do this (size the charcters ) while the Charformat only Contains a
yHeight member I wonder if yOffset data member in CharForamt is the
same as the lfWidth member in the LOGFONT data structure
thankx again
|
|
|
|
 |
|
|
General News Question Answer Joke Rant Admin
|