|
Hi guys
Once again, please excuse me if this is way too simple... oh those newbies...
If I have to read a file with many lines of data, it would be useful for the user to be able to identify any particular entry that wants to be modified. Of course, the code that reads the data (or the manual) tells what it is, but for the user it would be easier if information could be added to the file that has the data with the program ignoring those bits of information. I'd appreciate any simple solution to this.
Thanks a million!
|
|
|
|
|
Do what all languages do - define a character sequence to indicate a comment. For example, in C++, it's // or /* ... */. Use a sequence that makes sense to your users, if they use VB, for example, use '. Then the trick is that any string that is valid and starts with ' needs to start with a known sequence to escape that character ( such as '' ).
The other way to do it is to use XML, and then HTML comments are valid.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
uh... either I didn't make myself clear or I didn't understand your response. Of course I know that INSIDE THE CODE I can use // or /*...*/. The question is how do I comment in a file to be read by the program, making the program ignore the comment... just the same as in the code but while reading the file. Say I have the following code:
int main()<br />
{<br />
int id;<br />
double Stuff;<br />
ifstream GetData;<br />
GetData.open("D:\\SSL\\Code\\Testing_Rutines\\FileComms\\comms.dat");<br />
if (! GetData.is_open())<br />
{ cout << "Error opening data file" << endl; exit (1); }<br />
else cout << "Commented file opened" << endl;<br />
<br />
while(!GetData.eof())<br />
{<br />
GetData >> id >> Stuff;<br />
cout << id << Stuff;<br />
}<br />
GetData.close();<br />
<br />
return 0;<br />
}<br />
And the data file has (with comments):
// first
1 2.3
// second
2 3.5
// third
3 9.8
where the program needs to ignore "// first" , "// second" and "// third".
If your response is that I need to "define a character sequence to indicate a comment" I have absolutely no idea how to do it. Both // and /*...*/ are already defined in C++ as comments inside the code, I don't have to define anything.
Thank you!
|
|
|
|
|
I'm saying that you read the data a line at a time, and check each line for the comment delimiter, and if it is there, ignore it for processing.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
That sounds as if you were recommending to read both the data and the comment and then just ignore/destroy the comment read. If so, that is something I don't want to do. I want to read the data only and if a comment is found ignore it, do not read it.
Thanks!
|
|
|
|
|
Then you're screwed. You can't know that a comment exists without reading it from disc and examining it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
As Christian is saying, if you're going to use a file where you're manually reading every line, then by definition, you'll have to manually parse the comment lines and ignore them. This is one argument for using XML as with XML you can specifically read data-only nodes and not read comment-nodes.
|
|
|
|
|
I allocate a CFileDialog for select and work on a file txt:
CFileDialog ldFile(TRUE, NULL, NULL, OFN_OVERWRITEPROMPT,"Text Files (*.txt)|*.txt||");
After... with data taken from this txt i have to do something with an access db that live in the same dir where the application has been executed:
m_db->Open(NULL, false, false, "ODBC;DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)};DSN='';DBQ=article.mdb");
The problem is that the app search article.mdb in the same dir where the user have been selected the txt file...
How can i do for read the db in the same dir of the app?
|
|
|
|
|
TCHAR buff[MAX_PATH];
GetModuleFileName(NULL, buff, MAX_PATH);
char drive[3];
char dir[MAX_PATH];
char fname[MAX_PATH];
char ext[MAX_PATH];
_splitpath(buff, drive, dir, fname, ext);
|
|
|
|
|
I am writing a C++ DLL that is accessed by a VB form.
The problem I have is that I need to use methods in the DLL that deal with an object that I cannot pass back to the VB form.
So far the only way I have found to get around this problem is by wrapping the C++ class and creating an instance of it, then passing the pointer to that instance back to VB. Whenever VB calls a method it includes the integer (object pointer) in order for the C++ code to reference the instance of the class.
However, I don't want to have to create a wrapper like this. Is there any way for me to make the methods and the objects created in the DLL static so that they can be accessed through multiple method calls from VB without passing this object pointer?
|
|
|
|
|
CimTaurus wrote:
Is there any way for me to make the methods and the objects created in the DLL static so that they can be accessed through multiple method calls from VB without passing this object pointer?
it's tough to say, without knowing how these object[s] are used by your system.
if the VB code only ever uses a single object instance in the C++ code, you could just make the object global in the DLL, and have all method calls use that global object.
DLL
-------------------
global exported
objects: functions:
<-- FooMethod1(...)
CFoo <-- FooMethod2(...)
<-- FooMethod3(...)
<-- BarMethod1(...)
CBar <-- BarMethod2(...)
<-- BarMethod3(...)
-------------------
if you want to operate on multiple instances of the CFoo and CBar objects, though, you'll need a way to distinguish them externally, and in that case, the object pointer is as good as any other method.
what is it about the way you're doing it that you don't like?
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
A project I'm working on has me updating some app generated e-mail code (that used Simple MAPI) so that it can send image attachments that show up inline as part of an html message instead of simply as attachments. I used CDO for this, which worked great once I could finally figure out how it all worked (worst part is most of the MSDN samples were usually missing one key component to get it to work ... grr). I'm almost done, except for one little problem. What I want to do is open the generated e-mail up with the default e-mail program, to allow the user to change the message as they want and put in recipients. But, using the IMessage's Send function, the call will fail unless there is a recipient specified ... in other words, it will only send the message silently, without user interaction.
With simple MAPI, I can simply call SendMail with the MAPI_LOGON_UI|MAPI_DIALOG flags, and it opens up the e-mail in the e-mail client. This works great, and is what the old code used to do. Too bad I can't use this function with the IMessage message.
From what I can see from sample source and other documentation, with pretty much any other language supported by microsoft, the Send function I'm calling has a ShowDialog parameter that allows you to pop-up the dialog like I want it to (I'm so sick of seeing VB examples like this I could just puke). Unfortunately, this function is not available with C++, it only has the one version that takes no parameters.
One line of thought I had was to save the email out as a temporary file, then send open it with a shell command .. but that won't work quite right either, the generated e-mail can be saved as a .eml file, which opens up in Outlook Express ... not the default e-mail program, and even that doesn't quite work the way I intend either.
I've been searching through MSDN and the web for over a day now, and because the functionality is there for other languages, I know there has to be a setting or field I can set to allow this ... but I can't find anything. Anyone go through something similar, or have some other place I can look?
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
how can I load a bitmap from file and display it inside (let's say) a static control?
thank you
|
|
|
|
|
|
A. You can go to Resource Editor and add bitmap to your resources. Add static picture control to your dialog, make it type bitmap and set the ID of the bitmap you loaded as resource for this control. This is done before you compile.
B. Use an imaging library. I like FreeImage. There are others: CxImage, DevIL etc etc. So loading a bitmap depends on the library you use. There's some code
http://freeimage.sourceforge.net/developers.html#faq. Once you load the image, override the class for the user control you're using and implement OnPaint() function to draw the bitmap you loaded.
This should get you started.
|
|
|
|
|
i want to count print outs printed by printer is any way to do this plz suggest me.
i am making cyber cafe managing software i need to count print out in my program
|
|
|
|
|
How can I programatically find out if MS Excel is installed on a PC and where it resides?
Thanx!!
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
I would reccomend going through the Registry. Read HKEY_CLASSES_ROOT\.xls and see what the associated program name is. If this key doesn't exist you know right away that Excel is probably not installed. Next take the value read from the default value (usually something like "Excel.Sheet.8") and look for it in the registry with the command path appended:
HKEY_CLASSES_ROOT\Excel.Sheet.8\shell\Open\command
The default value of that key will tell you the location of Excel. You will have to parse it up a bit though. Hope that helps.
|
|
|
|
|
HKLM/Software/Microsoft/Office/<Version>/Common/FilesPaths
|
|
|
|
|
Thx!!
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Hey All,
I have a property page with an embedded CFrameWnd that is the child of the page. I can add CToolbars and a CStatusbar with absolutely no problems, and I am using a CRichEditCtrl for the view. But I am unable to add a menu to the frame. Calling SetMenu() fails and GetLastError() returns 0x59c ==> Child windows can not have menus.
Does anyone know of a way that I can add a menu to a child CFrameWnd, in such a way that the default toolbars still work? I tried Yao Zhifeng's CMenuBarXP class[^]. While it did put a menu in place, it did not cooperate with the layout mechanism of the frame and would simply draw itself overtop the toolbar and/or the edit control.
Basicly what I am after is to embed a complete SDI frame window into a CPropertyPage. Any links or hints would be appreciated.
"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! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Off of the top of my head, there would be two things that I would try:
1: "Fake" it, by creating a toolbar that uses text for buttons and then activate menus in-place when the buttons are pressed, kinda how some dockable menu systems work
2: Embed the menu in a rebar, and place the rebar in the window.
Hey - can you add a menu to a CDialogBar? If so, you can dock it to the top of the frame.)
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Thanks for the suggestions James. I will look into the rebar and dialogbar options. The first option of "faking" it does not appeal to me at the moment, but may end up being the choice of last resort.
I was actually hoping for a link to an article written by someone who had already done this and had figured everything out.
"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! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
i was surfing the whole noon just looking on how to create a shared folder over network with permission. i also couldn't found any example in MSDN. at last i found some code snippets on some forum.. anyone could give some code snippets? thanks in advanced.
SECURITY_INFORMATION SecurityInformation;
SecurityInformation = OWNER_SECURITY_INFORMATION;
SECURITY_DESCRIPTOR SecurityDescriptor;
ACL Acl;
SID Sid;
DWORD dwAclAllowed;
dwAclAllowed = sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(&Sid);
InitializeAcl(&Acl, dwAclAllowed, ACL_REVISION);
InitializeSecurityDescriptor(&SecurityDescriptor, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorOwner(&SecurityDescriptor, &Sid, TRUE);
SetSecurityDescriptorGroup(&SecurityDescriptor, &Sid, TRUE);
SetSecurityDescriptorDacl(&SecurityDescriptor, TRUE, &Acl, TRUE);
SetSecurityDescriptorSacl(&SecurityDescriptor, TRUE, &Acl, TRUE);
SetFileSecurity(strOCRDownloadFontLibPath, SecurityInformation, &SecurityDescriptor);
from,
-= aLbert =-
|
|
|
|
|
This may be a general doubt but I do need clarification .
I have declared a userdefined class object m_pElement as a member of CMainFrame.
I want to release its memory in the destructor in the foll.manner.
CMainFrame::~CMainFrame()
{
if (m_pElement)
delete m_Element;
}
But if I had not declared memory for pElement using 'new' the above destruction leads to exception.
How to check for allocated memory and then release the memory for pElement.
laiju
|
|
|
|