|
|
How can I change the content of the status bar of the main frame in view.cpp ?
Thanks!
|
|
|
|
|
Last I read it was very difficult to alter the text in pane 0. This is because the MFC framework is always writing something to it, so even if you wrote something else to it, it would only last a fraction of a second until MFC changed it. Depending on what you are doing, it might be better to create a second pane and write to it.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
With the following steps:
1.Define a value,such as ID_FO_INDEX_MOUSEPOS.
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_FO_INDEX_MOUSEPOS,
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
2.Add a update message to your view.
afx_msg void OnUpdateMousePos(CCmdUI *pCmdUI);
ON_UPDATE_COMMAND_UI(ID_FO_INDEX_MOUSEPOS, OnUpdateMousePos)
3.Change it with the following style:
void CFOPCanvasCore::OnUpdateMousePos(CCmdUI *pCmdUI)
{
pCmdUI->SetText(m_IndMousePosString);
}
Jack
---------------------------------------------------------------------------------
XD++ MFC/C++ Flow/Diagram Library -- http://www.ucancode.net
|
|
|
|
|
You'll also need a stringtable entry for ID_FO_INDEX_MOUSEPOS in the project's .rc file.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Is there a way to open up a word document as read-only when it's not a read-only file to begin with. I opened up my file using CreateProcess. Is there a way to do this? Thanks!
|
|
|
|
|
CreateProcess() does not open files !!!!!!!
if you want to open a file with the ReadOnly option, you could do this :
std::ifstream file("theFile.txt");
or
fopen("theFile.txt", "r");
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I tried the following and still won't open up. I want to open it up in MS Word which was why I used CreateProcess. What did I do wrong? Thanks!
FILE * pFile;
pFile = fopen (filename,"r");
if (pFile!=NULL)
{
fputs ("fopen example",pFile);
fclose (pFile);
}
|
|
|
|
|
Is using ShellExecute() out of the question?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
No but how is it different from CreateProcess? There seems to be no parameters that specify it as read-only.
|
|
|
|
|
I see, you are trying to open with word and not with your own program for reading. What you want to do will probably need to use word OLE automation. I would suggest doing some searching for just that, it's not as simple as just executing the program to do this. It's actually not much more code but understanding the concepts is a bit more complex. I haven't done this sort of thing in a long time so I don't know the code off hand, but I'm sure a quick google search will find something.
-- Rocky Dean Pulley
|
|
|
|
|
I found a simpler way. Before opening up the document in Word, I used GetFileAttributes() to get its file attribute. If the returned value is not read-only, I called SetFileAttributes to set it so and then use CreateProcess to open it up within Word. Much simpler. Thanks for your help though.
|
|
|
|
|
Assuming that you meant CreateFile, pass the second parameter as GENERIC_READ.
-- Rocky Dean Pulley
|
|
|
|
|
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]
|
|
|
|