|
If you talk about ON_COMMAND handlers and such, as I guess, you are free to place them where they are the most "natural". CDoc is great if you need access to the Data your application is working on, in CView you handle a button like "Redraw", which is only interesting for the View.
Generally, if you need ugly casts, you should look for a better site of the handler (but sometimes you just HAVE TO cast).
|
|
|
|
|
Thanks for your replies guys! Just want to make sure we are talking the same thing here. Basically I am confused about where to place my menuitem handler, ie, OnMyMenuItem. They could exist in all the DOC/VIEW/MainFrm, and the functions are accessible in all of them also. Just don't know the different between them. I am working in with a SDI program. So probably, I will be working either with CView/CDoc or Mainfrm/CDoc , right? There isn't much different with CView and Mainfrm since they are the same?
|
|
|
|
|
For me, the CMainFrame(-derived) class is something technical, which tends to be almost empty.
It is not concerned with the data of my application, rather with window-drawing issues.
My application data is stored in the CDoc, and most manipulation routines are there.
My CView get the data (or rather references to it) and put it on the screen in a ordered fashion (like vector of numbers to line plot).
So - my menu handlers are almost always in CView/CDoc, and CMainFrame is empty and boring.
|
|
|
|
|
I want to add tree control in the left view of my SDI application in MFC, also i want to add events regarding each Child node of the tree..
Any Help ??
ThankU
|
|
|
|
|
Since you are working in an SDI environment, I am assuming that you have a splitter pane, and that yout left view is the left pane.
A splitter pane is contained and created in your MainFrame class, probably in OnCreateClient(). Locate the code and find the section which creates the views. With some work you can replace the current left view (which is probably a CView) with a class derived from CTreeView.
An easier approach is to use ClassWizard to generate an 'Explorer Style' application. You can also do this to study the code which class wizard generates and then modify your current application.
--James Pullicino
Drinking In The Sun
Forgot Password?
|
|
|
|
|
Hi All,
I need to assign a simple string say "Administrator" to the LPCWSTR variable within the program.How do I do it.Is there some type casting available to do this.
Thanks
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
u mean how to assign a char buffer to a wide-char (short char) buffer, do it as:
char*psz=new char[100];
psz[99]=0;
WORD*pwsz=new WORD[100];
while(*psz!=0)
{
*pwsz=(WORD)*psz;
psz++;
pwsz++;
}
*pwsz=0;
includeh10
|
|
|
|
|
LPCWSTR var = L"Administrator";
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
Thanks a Lot
Regards
Abhishek.
|
|
|
|
|
Hi.
Is there a function to convert a text from a clipboard to its original form including individual lines? For example, let say you copy three lines of text and then paste it in Notepade. How does it know there texts' original format?
I have some ideas and one of which is to scan the character array and search for '/n' or "/r/n."
Thanks,
Kuphryn
|
|
|
|
|
That sounds like a good plan to me!
The data must be in a registered clipboard format, and CF_TEXT (or CF_UNICODETEXT) is probably the one to ask for. This gives you the raw character (or wide character data), and it will have embedded newline or carriage-return/newline pairs as they were placed in by the source of the cut or copy.
You could use a CString and the Find() member, or if not, then something like strchr, wcschr or for portability, _tcschr would help you find the line breaks. If you are happy to modify a copy of the data, strtok (_tcstok) would be easy enough.
Steve S
[This signature space for rent]
|
|
|
|
|
the process is
1. check clipboard format (text in ur case)
2. get the data
3. the data should be: line0\r\nline1\r\nline2 if 3 lines for nodepad
includeh10
|
|
|
|
|
Okay. Thanks everyone.
Kuphryn
|
|
|
|
|
in CDocument sub-class, i create a thread to access a buffer, at the CDocument closing time, sometimes a run-time happens. i don't know why.
coding as this:
class MyDoc: public CDocument
{
..................
//they are init as null in constructor
HANDLE hThread;
BOOL bLoop;
DWORD dwThreadID;
char*pBuf;
};
MyDoc:OnOpenDocument(...)
{
pBuf=new char [50000];
hThreat=CreateThread((LPSECURITY_ATTRIBUTES)0,0,
(LPTHREAD_START_ROUTINE)Proc_Thread,
this,0,&dwThreadID);
.........................
}
void MyDoc::OnCloseDocument()
{
bLoop=0;
if(hThread)CloseHandle(hThread);
if(dwThreadID)::PostThreadMessage(dwThreadID,WM_QUIT,0,0);
::WaitForSingleObject(hThread,(UINT)(-1));
delete []pBuf;
................................
}
int WINAPI Proc_Thread(void*pVoid)
{
MyDoc*p=(MyDoc*)pVoid;
char*pBuf=p->pBuf;
while(p->bLoop)
{
//access pBuf
}
return 1;
}
note: the only problem is at closing time.
is something wrong with the coding?
thx
includeh10
|
|
|
|
|
Post a message at the end of Proc_Thread() informing the primary thread that the worker thread has closed. That will help make synchronization smoother.
Kuphryn
|
|
|
|
|
Another alternative would be to WaitForSingleEvent on the thread handle in your UI thread, to guarantee that the worker thread has completed.
When the "primary" thread terminates, this usually calls ExitProcess at some stage, which kind of tears things from under the feet of other threads...
Steve S
[This signature space for rent]
|
|
|
|
|
but i can't find the function WaitForSingleEvent?
thx
|
|
|
|
|
Ah. That's because I meant to type WaitForSingleObject instead.
Sorry about that, it's early in the morning here, and I didn't get much sleep.
Steve S
[This signature space available for rent]
|
|
|
|
|
thx, it is 100% new for me, but what does post a message mean?
post what messge? inside or outside loop?
please give me more details.
thx
includeh10
|
|
|
|