|
You probably like access to your Orders object from all functions in the Dialog. In this case it makes sense to declare your orders object as amember variable. Member variables should be defined in the class declaration (in the header file). Then the object can be used inside the class.
|
|
|
|
|
I think I am having trouble moving from use of main() in console based C++ to VC++. In console I could do the following:
int main()
{
Limits Lim;
Transaction Tran;
int iResult;
iResult = Lim.ScanForValidity(Tran.ItemCode);
}
This allowed a function from one class to get data from another. In VC++ I find a wall between classes that I can't get through. I can do whatever I want within the various functions of the same class, but can't get the data out of the class.
Since I had main(), I never needed to reference a function of classABC from a function of classXYZ.
If I write function SetSomething() for a class, I cannot reference the SetSomething() function in a function of any other class. So, I can't "set" anything.
Likewise, if I write a function GetSomething() for a class, I can't reference the GetSomething() function in a function of any other class. So, I can't "get" anything.
I am defing all my classes in the same .h header file. I am coding the all the functions in the same .cpp file.
Since VC++ works so well for so many people, I conclude the problem is with me. Suggestions?
|
|
|
|
|
Progress. I created an instance of my Orders class within the declaration of the CDialog derived class. This lets the CDialog derived class deal with the Orders class functions and variables. (I think this is what Rudolf suggesed, but it took a while to comprehend.)
//HeadClassDlg.h
class CHeadClassDlg : public CDialog
{
...
...
...
Orders Buy; // <----This is what worked
};
Now functions in HeadClassDlg can access variables and functions from the Buy object of class Orders.
Thanks for the help.
|
|
|
|
|
I'm trying to understand what I'm doing right now from a high level point of view. Fitting it in to a formal design pattern often helps me formalize my thinking. This hunk of code though is eluding my classifying abilities and I'd like to hear your opinions.
My networking API works on the premise of messages as the base component. The next layer above that is sort of like a request-response system. For example you request the server version number, perhaps to ensure messages are handled the same way at the server\client ends, and receive a concrete type, say a pair of integers.
This is almost similar to to the command pattern for the response part, where the network server class transforms a packet back in to a class. When the response to a request has come back I need something similar to a callback to let the requestor get it's data.
To represent that, I need to call in to something (my app is multithreaded). What I devised was a series of standard response types, Integer response, string response, VectorOfStrings response, etc. The trouble with this model is that I'll have to keep creating response types to all the different scenarios, VectorOfInts etc, etc...
Is there a better way?
|
|
|
|
|
I'm working on something similar to this. I started by looking at various Socket and MOM libararies here on CP and elsewhere. Two in particular are MQ4CPP and Muscle. In the end these were not what I wanted, but they helped provide a better understanding of sockets, messaging etc.
So I've written my own simple implementation. I've not used the callback approach as I have a simple protocol which can be handled in a procedural fashion. In order to handle the various types of data (int, string, file etc) I've used the CDiggins any class which is here on CP. This has kept my interface into the socket code simple as it only uses any's. An any is a variant that can hold anything.
There is also an article here on CP that uses a state machine approach, which you may find of itnerest.
I've got all this stuff in Surfulater, so let me know if you need any links. HTH
|
|
|
|
|
Hi,
I have an application that creates a word document with couple of lines of text. I do not use MFC. Does anyone know how can I change my font (to Courier New).
I add text like that sp setting the font should work similarly:
szFunction = OLESTR("TypeText");
hr = pDispSel->GetIDsOfNames(IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT, &dispid_TypeText);
then I set text and...
hr = pDispSel->Invoke (dispid_TypeText, IID_NULL,
LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&dpTypeText, NULL, NULL, NULL);
Thanks a lot!!
|
|
|
|
|
I'm passing STL container classes to a dll to be initialized. The dll in turn uses threads to read a file. I compile the debug version of the dll using the 'Debug Multithreaded DLL' RTL, the same for the main exe. If I build a release version of the dll and use it alongside the debug version of the exe I get invalid heap errors. I'm guessing debug and release builds should not be mixed but could somebody clarify this?
|
|
|
|
|
The Debug version of new and delete use some extra memory buffers to detect things like memory overruns. Trying to mix Debug and Release versions of Dlls/EXEs can cause things like that. Also, STL containers are not thread safe, so you will need to protect them within the DLL.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: Also, STL containers are not thread safe, so you will need to protect them within the DLL.
I missread the MSDN docs on that one. How would you protect them? Locking the memory?
|
|
|
|
|
the debug versions of malloc/free and new/delete are different from the release versions.
MSFT:
If you do choose to mix CRT libraries, remember that you have two separate copies of the CRT, with separate and distinct states, so you must be careful about what you try to do across a CRT-boundary. There are many ways to get into trouble with two CRTs. Here are just a few:
• There are two separate heaps. You cannot allocate (explicitly with new, malloc, or so on -- or implicitly with strdup, strstreambuf::str, or so on), and then pass the pointer across a CRT-boundary to be freed.
• You cannot pass a FILE* or file handle across a CRT-boundary and expect the "stdio low-level IO" to work.
• You cannot set the locale in one and expect the other's locale to be set.
|
|
|
|
|
I'm attempting to display a drag image using IDropTargetHelper but it's not working. I can call CoCreateInstance(CLSID_DragDropHelper, NULL, CLSCTX_INPROC_SERVER, IID_IDropTargetHelper, (LPVOID*)&m_spdth) and get a pointer, but all calls to functions return a HRESULT of "Interface not registered".
I'm using Windows XP SP2 and my shell32.dll version is 6.0.2900.2951. I used TypeLib viewer to look in my shell32.dll and didn't find the IDropTargetHelper interface. Is there something I'm missing?
Edit: I just realised that while dragging within a single explorer window creates the SysDragImage window class, dragging it into another explorer window is broken as well. I wonder how long it has been since I noticed...
-- modified at 16:21 Monday 21st August, 2006
|
|
|
|
|
I need to be able to display the "space" in an edit box with something visual.
I'm trying to handle the EN_UPDATE message which seems to be the one message to use because it will be also handled when pasting text in the edit box.
I'm not certain how to go from there, I cannot re-set the text to the control, but this will trigger another EN_UPDATE message, and will have an infinite loop.
BEGIN_MESSAGE_MAP(CMaxEdit, CEdit)
ON_CONTROL_REFLECT(EN_UPDATE, OnEnUpdate)
END_MESSAGE_MAP()
void CMaxEdit::OnEnUpdate()
{
CString s;
GetWindowText( s );
s.Replace( " ", "*" );
}
any suggestions ? I could not find the appropriate google query to have some usefull links.
Thanks.
Max.
|
|
|
|
|
void CMaxEdit::OnEnUpdate()
{
CString s;
GetWindowText( s );
if(s.Replace( " ", "*" )) SetWindowText(s ); // will trigger an infinite loop.
}
|
|
|
|
|
Set a flag in your EN_UPDATE handler to control execution:
void CMaxEdit::OnEnUpdate()
{
static bool InEnUpdate = false;
if (!InEnUpdate)
{
InEnUpdate = true;
InEnUpdate = false;
}
}
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Hello,
In my application, I need to write some results that have been obtained after doing calculations into a pdf file. I have seen articles on codeproject on how to convert text files into pdf. But text files will not have colouring etc.
I was wondering if it is possible to integrate an independent pdf writing software like pdf995 into my application and make it do the pdf writing silently.
Please advise.
Fortitudine Vincimus!
|
|
|
|
|
pdf995 just pretends to be a printer, so you can print anything you like to it - one solution would be to generate a html table of your data, and print that to pdf.
|
|
|
|
|
benjymous wrote: print that to pdf.
Print to pdf by making the application to choose the pdf995's ( or any other pdf printer) printer silently? Is that right? If that is so, how can I silently choose the printer and execute the print command?
Fortitudine Vincimus!
|
|
|
|
|
Just write your own pdf exporter. It takes a bit of time but it frees you from other peoples code from that day forward. It took me about 6 months to write a GDI/GDI+ compatible, xml parsing PDF exporter that I can now use in all my apps. Well worth the time and effort.
PDF Reference Fifth Edition[^]
|
|
|
|
|
Hello,
I am trying to write simple text of different colors to pdf. So far I have been able to write a string of grey color to pdf. But I need to write other lines too with blue color. Please can you guide me on how to do this?
If we use BT for start of text object and ET for end, a string can be written of a particular font and color.
Now if I have to write another string of some other color, do I have to use another set of BT and ET? I tried it this way but it is not working. Either I have missed the topic in the pdf manual or am not understanding something.
Any help will be highly appreciated.
Thanks.
Fortitudine Vincimus!
|
|
|
|
|
Tara14 wrote: do I have to use another set of BT and ET?
That's how I do it.
"BT /F1 30 Tf 100 -100 Td (Test) Tj ET\n"
/* NOTE: I make my Y axis match my GDI/GDI+ mapping mode so you may find things a little different in terms of the Y axis in your environment. I use MM_ISOTROPIC and I make sure the Y goes downward as it increments so I set all my PDF media boxes accordingly. PDF default rect is left/bottom to right/top which did not make it easy to reuse my GDI/GDI+ action data unless I flipped it around */
Also, PDF will keep track of it's graphics state. This means you only need to change the stroke color, stroke width, fill color etc... when they change. You can choose to explicitly set it on each drawing command but you can save lots of file space if you only change it when you need to.
Does your output format resemble the above (ignoring the values of course)?
|
|
|
|
|
Thank you for your reply.
bob16972 wrote: Does your output format resemble the above (ignoring the values of course)?
Yes. The format is exacly like this. In palce of (Text) I enter in the string that should be written to pdf. Lines are seperated by T*(Text)Tj.
bob16972 wrote: "BT /F1 30 Tf 100 -100 Td (Test) Tj ET\n"
I am a bit confused here. /F is the font type, right?
Whatever font is being used must be described earlier in the font dictionary, right?
Is <code>(Text)</code> the entire text that is being written to pdf? Suppose the text is something from a doc file.
If yes, how does the pdf know which part of the text uses which font and which color?
You mentiond that "Also, PDF will keep track of its graphics state. This means you only need to change the...."
I do not understand this. Please can you elaborate a little.
Thank you once again for your help.
Fortitudine Vincimus!
|
|
|
|
|
Tara14 wrote: I am a bit confused here. /F is the font type, right?
That is the resource name. A good example of this is on page 270 (292 of 1236) of the PDF Specification 1.6
Tara14 wrote: Whatever font is being used must be described earlier in the font dictionary, right?
PDF is written to be read somewhat backward but I believe you will see many different ways of laying the file out. The rules are very confusing and complex in my opinion. My implementation ends up declaring the font descriptor objects toward the front but the resource names get associated with the font descriptors in my Pages object which happens to be toward the end of my file slightly before the Cross Reference and the Trailer. However, you can lay your file out in any way that does not violate the rules in the specification so it would be wrong for me to say yes or no to this question.
Tara14 wrote: Is (Text) the entire text that is being written to pdf?
Yes (Except for the parenthesis of course). Don't forget to apply PDF escape sequences as described on page 30 (52 of 1236) of PDF Specification 1.6 to prevent string literal characters from conflicting with the PDF file.
Tara14 wrote: Suppose the text is something from a doc file.
If yes, how does the pdf know which part of the text uses which font and which color?
It is up to you to tell PDF what to render and how to render it. If you don't know how to parse the doc file, you will be unable to tell PDF what to draw and where and with what color etc...
My documents are described in XML so I parse the information that describes the action of drawing each graphics primitive (lines, bezier curves, rectangles, and Text) and then I translate it to a GDI/GDI+ graphics primitive command if drawing to the screen or printing or to PDF postscript that corresponds to the equivalent PDF graphics primitive command if exporting to PDF. If you do not have the information necessary to parse the doc file, you will have to resort to a print driver strategy like some vendors but I'm afraid I have no experience there and would be of little help.
Tara14 wrote: You mentiond that "Also, PDF will keep track of its graphics state. This means you only need to change the...."
I do not understand this. Please can you elaborate a little.
For example...
If you set the Stroke color to red, all subsequent graphics commands will use red for the stroke color until the graphics state goes out of scope (as described in the specification) or until the Stroke color is explicitly set/changed by you. If the Fill color is set to blue all subsequent graphics commands that use a fill color will use blue until the graphics state goes out of scope or until the fill color is explicitely set/changed by you. etc...
I hope that helps
|
|
|
|
|
Thanks a lot for your patience. I am begining to understand quite a lot now.
This is a bit complex and confusing, but I guess the more I read the manual, the better I will understand.
Thank you once again.
Fortitudine Vincimus!
|
|
|
|
|
Hello,
Is there anyway I can open the pdf from the application one it is created? Shellexecute is not working.
I searched codeproject and found "A simple wrapper to control Acrobat Reader from your application, By seasidetech." but it does not work if adobe is not already open. And I am not able to understand why.
Please help.
Thanks.
Fortitudine Vincimus!
|
|
|
|
|
I'm not sure what you mean when you say ShellExecute is not working. Once I export my .pdf to some path, I call ShellExecute to display it. This is of course assuming Adobe Reader is installed on the machine using the "open" verb
// Note: pApp obtained via AfxGetApp()
ShellExecute(pApp->m_pMainWnd->GetSafeHwnd(),"open",sPath,NULL,NULL,SW_SHOWMAXIMIZED);
|
|
|
|