|
Sorry, nevermind. I get it.
|
|
|
|
|
Still have a question though... I thought CString::Left() would work, but it's not working the way I expected either.
So, how do I trim off the first part of this string, to get only the city and state? Better yet, how can I get the current directory, pass that to a CString, and then strip that value out of another string, as per the example above?
Thanks,
Wolf
|
|
|
|
|
I have been single stepping through this code and still have not found out what is happening. I have learned that if you substiture A in Anchorage with a printf white space formating character (n, t, f) then the same problem occurs.
I recommend that you write your own TrimLeft() routine, it is easy to do.
Good luck!
Oh and thanks for the puzzler. I'll find a solution eventualy, but not today.
INTP
|
|
|
|
|
Thanks for your response. I've got it now. TrimLeft() (after a little RTFM'ing) removes ALL characters from the left that you specify, not the string as it appears. So, what I did was subtract the length of the current directory from the length of the entire string, and then use that number to extract only the data I wanted from the string, like so:
CString m_Fairbanks = _T("C:\\Project\\Final\\Data\\Fairbanks, AK");
int FairbanksLength = strlen(m_Fairbanks);
TCHAR SourcePath[MAX_PATH+1] = {0};
GetCurrentDirectory(MAX_PATH,SourcePath);
int DirLength = strlen(SourcePath);
int DataLength = FairbanksLength - DirLength;
CString string = m_Fairbanks.Right(DataLength-1);
MessageBox(string,NULL,MB_OK);
I'm actually loading the data from an XML file and overriding an OnBeforeNavigate2() message from a WebBrowser Control, so it thinks it's a URL (VARIANT) and adding the local path to the element, which isn't what I wanted. It seems to be working now though.
Thanks again,
Wolf
|
|
|
|
|
I think PathStripPath will do what you want.
The PathXxx APIs are very powerful.
|
|
|
|
|
Greetings,
Please bare with me as I am rather new to Microsoft Visual C++ and haven't coded in C in many years.
I have searched for as many examples as I was able to find but nothing has helped me understand my needs at this point in time.
I have an application that has the following requirements:
NOTE: The coding in done in NON MFC C code using Microsoft Visual C++. (That was a requirement handed down to me.)
1. Read in a specially delimited file and display it's contents, one row per each delimited section. (This is done and works perfectly)
2. Form all those rows, pick one, a bunch of them, or none.
3. When the print button is clickes, take those choices (in the case of none, all the rows are printed) and print the information to a special Barcode Printer.
Now my problem is this.
Although I have found many examples of printing and can get data printed to our lazer printer, I am having problems getting it to line up exactly as I wish it to be. I am using the GDI TEXTOUT functionality to print.
Should I be using something different like creating a Bitmap and printing it that way? If so then I am in need of help on how to actually create a bitmap from scratch programatically.
I have searched and all the examples I was able to find only deals with loading and existing bitmap and massaging it in different ways to get different effects.
Also, I wish to be able to print to these printers using the windows drivers instead of specifically code for the printer.
Any help on this problem would be wonderfully greatful and please bare with me if I ask a few stupid questions along the way. I am finding it confusing at the moment and when the light clicks on, I might actually get somewhere. This is pretty much the last thing left to complete the project.
Tagni.
|
|
|
|
|
"NON MFC C code using" sounds like use ANSI C coding to me.
If you do not have a copy of Charles Petzod "Programming Windows" around then get it (a must have, all C).
1) Should I be using something different like creating a Bitmap and printing it that way?
Answer: no (normaly)
Last resort:
Even though you are not using MFC, it may be possible to take advantage of it via examination. Example: Load up WordPad example program and single step through the printing porcedure, to see how MFC is handling the printing.
Do not forget MFC is mostly a wrapper around C code, and C++ is a supper set of C.
:(I hope this at least helps a little.
INTP
|
|
|
|
|
I do have that book and have read it over a couple of times but I really do not quite grasp what is needed to get the printer to print using barcodes. I feel so confused when looking at it. I tend to learn better by example then by reading a book. And yes your right it's ANSI C. (Shows you how new I am at this stuff.)
That's why I thought I might have to create a bitmap to print. I also need to be able to print to any of the different kinds of barcode printers without having to code internally for each and every different one. Which is why we want to use windows print drivers for the process.
I do appreciate your reply. And I was not aware of the MFC wrapper thing, but that does help me a bit in understanding more about visual c++.
Tagni
|
|
|
|
|
I did not relise you where printing any barcodes. That would require using bitmaps or you could look into using meta files (code), I've never had a call to use meta code my self. Any time you print any thing using GDI, you are using a print driver. GDI just provides an universal interface to display devices, there by allowing you to use many of the same routines to print to all of them. I have rarley done any printing to a printer and so do not have any examples. At this point in time if I was going to write a program in C to print barcodes, then I would look at the articles here at code project first to see how some one did it using MFC. The reason for this is that there is a least one acticle on the subject here and I beleive I could figure it out from there.
Programming provides both joy and frustration.
Joys: Learning and solving of new problems.
Frustrations: Having to do it on someone elses time line and having to spend hours/days/weeks trying to find the information needed to solve those problems.
May your joys be many and your frustations few.
INTP
|
|
|
|
|
Why is it that a CStatic control (when adding a member varible) it doesn't offer the option for CString (like VC++6) and when I do set it to a char or CString it doesn't show it on MessageBox or can't change it.
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
The Visual Studio wizards are quite powerful, but they don't do everything you might want.
If you want to add a CString variable to map to a static control (replicating exactly what VC6 does):- Add a CString variable to the header file for the dialog, marking it
public . - (Optional) Add a line to the constructor, initialising the variable.
- In
DoDataExchange , add a call to DDX_Text , passing the pDX pointer, the ID of the control, and the CString variable.
|
|
|
|
|
I need to print the contents of a CListCtrl but don't have any experience with printing.
I looked at Chris Maunders's Printing without the Document/View framework article and it seemed to me I have to do all the drawing by my self. Isn't there a easier way to do this?
|
|
|
|
|
There are some CListCtrl printing articles in the CListCtrl section. Chris decided to keep code such as this with the control type and not in the printing section.
Here is a reference to one such article http://www.codeproject.com/listctrl/listprint.asp[^]
Not sure if it addresses all your needs.
Roger Allen - Sonork 100.10016
If your dead and reading this, then you have no life!
|
|
|
|
|
Hi Roger, thanks for your reply. It seems a lot of overhead (+/- 11 classes) for just 'simply' printing the contents of a listcontrol, but it is a start.
|
|
|
|
|
I am writing a dialog based application with menus. Trying to place a check on a menu item using
pCmdUI->SetCheck(1);
in the UPDATE_COMMAND_UI message handler function, it has no effect. Doing the same thing in a SDI application works fine. Am I doing something wrong? and suggestions? I am using VC++ 6.0.
Thanks
Joseph Colosi
|
|
|
|
|
|
Managing memory (leaks and overwrites) was quite easy when were using plain C.
We just had to define malloc(size) and free(ptr) to point to our own OurMalloc(size) and OurFree(ptr).
From that moment on we could add wonderful stuff to OurMalloc and OurFree like pooling memory chunks, checking for overwrites (using red zones before and after the allocated areas), checking for leaks, even storing the call stack at the moment of the malloc so a decent memory leak could be reported at the end of the program.
Then came C++. This was a bit more difficult since we now also had to reroute the new and delete operator. But after some investigation we found out how to implement those operators to forward their calls again to OurMalloc and OurFree.
Then came MFC. MFC (we use the most recent Visual Studio .Net) does not like the redirection of the global new and delete. You get all kinds of nice linking errors and warnings and even if you succeed in compiling it, you're guaranteed to have run-time crashes because your own new and delete is used instead of the MFC ones --> BIG PROBLEM.
So we end up with our old plain C code using our own advanced memory manager, and the C++ code (using MFC) that uses the MFC memory manager.
That's not the only problem: once in a while, our defines of malloc and free causes problems if an external include file (of the compiler or a 3rd party) has a method free defined in a class and it is called in an inline method. Then our own OurFree is called instead of the class's free method --> BIG PROBLEM.
I tried to look up methods of using custom memory allocators but only find methods that can only be used in a debug version (e.g. malloc_dbg, _CrtSetAllocHook, DEBUG_NEW, ...) and no method that works in release executables as well.
What I want to obtain is the following:
Having a memory manager that performs memory pooling (in debug and release builds), checks for overwrites, leaks and reports the call stack for leaks (in debug builds). External tools like Purify often give rubbish output so that's not an option to check for leaks.
Having a memory manager that can be used for plain C calls (malloc,free) and C++ new and delete 'calls' with and without MFC.
Is there a good article on how to add a custom memory manager to C/C++/MFC?
Are there any good commercial or freeware or open source memory managers that perform these tasks and can be used with plain C, C++ and MFC?
Thanks for your input.
Enjoy life, this is not a rehearsal !!!
|
|
|
|
|
The question speaks for itself.
The function SetWizardButtons() does not have an option for
disabling the "Help" button which appears at the bottom of
the property sheet, after the "Finish" button.
Any ideas?
Have no fear of perfection - You will never reach it
|
|
|
|
|
From MSDN
Help in CPropertySheet is supported by the F1 key and the Help button only. The Help button appears in the application framework by default. No intervention by the user is necessary. When the user adds the help information for each of the pages inside the property sheet, the help mechanism automatically displays the help for that page when the Help button is clicked.
To remove the Help button from a property sheet, modify the sheet and all its pages as follows:
mySheet.m_psh.dwFlags &= ~PSH_HASHELP;
page1.m_psp.dwFlags &= ~PSP_HASHELP;
page2.m_psp.dwFlags &= ~PSP_HASHELP;
mySheet.AddPage( &page1 );
mySheet.AddPage( &page2 );
mySheet.DoModal();
The m_psh variable is of type PROPSHEETHEADER. The m_psp variables are of type PROPSHEETPAGE. If all the HASHELP flags are clear (PSH_HASHELP for the property sheet object, PSP_HASHELP for the property pages), the property sheet will be created without a Help button.
Michael
'Logic, my dear Zoe, merely enables one to be wrong with authority.' - The Doctor: The Wheel in Space
|
|
|
|
|
I get 11 for e_mcause in
if(!cRed.Open("E:\\red64.txt", CFile::modeRead,&e))
{
int h = e.m_cause;
}
the file exists in the dir. I searched in the vc folder for the 'cfileexception' to get the enumerated consts but it was only in .lib and .pdb files, but found it in:
appdefs.h which doesnt list my 11 (hex B).
#define DS_E_FILENOTFOUND 0x8004A004
#define DS_E_ENDOFFILE 0x8004A005
etc.......
Where do I find out what the error code is?
Thanks,
ns
|
|
|
|
|
m_cause is really only for backwards compatibility with 16-bit versions of MFC. It's a translation of the OS error code that can be found in m_lOsError (translated by CFileException::OsErrorToException ).
Code 11 maps to CFileException::sharingViolation (see AFX.H).
I worked this out by reading the source to CFile::Open in FILECORE.CPP , which is the usual technique for figuring out what MFC's up to. If you don't have the MFC source installed, install it from your Visual C++ or Visual Studio CDs.
|
|
|
|
|
Great! Thanks for the info!
I pointed my Open to another dir which has a copy of the same file, and it finds it there, even though the file is sitting in the original location I had Open pointing to. I dont know what I have done to the file that makes the exception happen in the original dir, i.e. how the sharing violation is happening.....
thanks,
ns
|
|
|
|
|
How do you resize a CListCtrl?
m_ctrlList.SetWindowPos(&CWnd::wndTopMost,0,0,cx,cy,SWP_SHOWWINDOW|SWP_DRAWFRAME);
I've also tested with SWP_NOCOPYBITS and SWP_FRAMECHANGED, but no change.
The listctrl is visible with the initial dimensions, but resizing doesn't seem to work.
Anybody with some help?
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
setting NULL for z-order ... and it works.
sorry for me being to fast with posting this question.
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
what is NNTP Addresss of this forum
|
|
|
|