|
CFile SrcFile;
CString SrcFileName="C:\\test.doc";
SrcFile.Open(SrcFileName,CFile::modeRead ,NULL);
|
|
|
|
|
I do not want to read the contents of the file. I want to be able to open the file in Microsoft Word or Notepad as read-only.
|
|
|
|
|
How can I declare a pointer pointing to the mainframe in view.cpp ?
(I want to use the mainframe object in view.cpp)
Thanks!
|
|
|
|
|
add a frame pointer member in your views,
so the MainFrame passes the this pointer (itself actually) to the child view that have now a pointer to its mainframe...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Anonymous wrote:
How can I declare a pointer pointing to the mainframe in view.cpp ?
In the view's .h file, just add a member variable of whatever type your frame is (e.g., CMainFrame ). To define and use that member variable, try AfxGetMainWnd() or GetParentFrame() .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
what does this mean?
struct abc {
int (*loop)();
}
int Off()
{
return 1;
}
abc->&Off;
i don't understand this sourcecode!
Thx for explaination!
|
|
|
|
|
abc is a structure that holds a pointer to a function which takes no arguments and returns an int. it's also missing a semicolon at the end.
i'm not sure what that last line is.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
<font color=blue>int</font> (*loop)(); this defines a pointer to function.
it means that abc structure is looking for its loop member any function that has the same signature (no parameters, and an int as returning value).
abc->&Off; this is not correct for me, as abc is a type (and so, not an instance of that struct) and loop is not static so we cannot directly apply to it the operator -> .
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
i forget some code to post here. abs is an instance of struct abc. doesn't make sense i just want to cut it someway.
abc->Loop = &Off();
what does this mean? has Loop the value 1?
|
|
|
|
|
ok, let's say that abc is an instance of the abc structure here (even if in theory, the compiler won't allow you to give it the same name as its type - it is not VB ! )
abd->Loop refers to the member Loop we talked about previously. actualy, if we use the operator -> , abc in a pointer to an instance of abc structure , otherwise we would have used the operator .
now, as Loop excpects a pointer to function, we have to pass it the adress of a function that have the same signature (no parameters, return an int).
that's what the function Off() looks to be.
so we use the "address of" operator & to pass the address of the Off() function into abc::Loop...
understood ?!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
thats all clear. thx i am not a noob but lazy to type :P
but i don't understand why the author wants the address of method Loop();
the return value would make sense in any way but the address ...
hm... thx for your time.
|
|
|
|
|
zuschauer1980 wrote:
hm... thx for your time.
no problem, i'm here your servant sire :->
i'd like to add a detail however.
we use such function to have a "changing behavior".
if you know a little about virtual functions on C++, or Delegates in VB, it is quite the same.
it permits you for a same call to use different functions.
for example :
<font color=blue>int</font> iVal = 0;
<font color=blue>int</font> Func1() {
<font color=blue>return</font> 1;
}
<font color=blue>int</font> Func2() {
<font color=blue>return</font> 2;
}
abc TmpAbc;
TmpAbc.Loop = &Func1;
iVal = TmpAbc.Loop(); <font color=green>
TmpAbc.Loop = &Func2;
iVal = TmpAbc.Loop(); <font color=green>
hope this help more now...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
ah like delegates. ok everything is clear. i know c#.
thx for your help.
regards!
|
|
|
|
|
|
it is all about managed code not modular one, u know?
|
|
|
|
|
Almost every program I have worked on uses some technqiue to convert enumberated values to strings (and vice-versa). I suspect I have seen a dozen or more different techniques when multi-language translation is factored in. I am curious to what preferences other developers have and any pros/cons they see with those techniques.
|
|
|
|
|
|
Sorry to be vague. Was wondering what generic techniques you use/recommend for implementing conversions between enumberated type values and string representations. Also curious how (of if) you would use a different technique for multi-language support/translation.
|
|
|
|
|
I created a class called EnumStringMap which maps enums to CString s and/or resource ids. The includes some handy-dandy helper methods that allow it to be used with a CComboBox . Unfortunately I can't post it because it's code written for work.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
TRY
CMap with integer as a KEY!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Does anyone know how to send HTML directly to the printer? I need to do this programmatically. I'm creating HTML files on the fly, and I'm able to display them properly using Internet Explorer. This provides sort of a "Print Preview" mechanism, but I can find no way automatically print it. It would be great if iexplore.exe had a command line option to print the document without bringing up the IE screen.
I've tried some sharewares that claim to do this, but the formatting is never correct. It seems like I need to get this to work with IE somehow.
Any suggestions are greatly appreciated.
|
|
|
|
|
This[^] article may help. Unfortunately, I think you'll still see the standard Print dialog box.
[edit]
If you can get a pointer to the document object within the web browser control, you may be able to use call ExecWB() with IDM_PRINT [^]. This command allows you to print without having to display a dialog to the user.
[/edit]
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
This command allows you to print without having to display a dialog to the user
Unfortunately, at least as of IE 6, that's no longer true. All mechanisms that print from the web browser control (script, ExecWB , etc.) now invoke the print dialog, even if you specified no interaction. This was changed as a security mechanism, to prevent malicious web pages from printing uncontrolled to the default printer. This change may have been applied retroactively to IE 5 and 5.5 via Windows Update, but I'm not sure.
Software Zen: delete this;
|
|
|
|
|
Hi,
I am porting a project from VC6 to VS 2003 and when I compile it, every file that contains #include <fstream.h> will tell me it cannot be found.
Of course I can start using CFile not but I just don't have the time to start modifying the code.
So,
Is there any other #include I can use to support all of my 'ofstream' and 'ifstream' functions I used in my code ?
Thanks,
Shay
|
|
|
|
|
The stl header declaration, <iostream.h> , etc. are all depreciated. Use <iostream> (without the .h) instead.
I Dream of Absolute Zero
|
|
|
|