|
You can use SetWindowText to put text into an Edit Control. Have a look at MSDN for syntax.
Michael
Programming is great. First they pay you to introduce bugs into software. Then they pay you to remove them again.
|
|
|
|
|
All right thanks for info.
|
|
|
|
|
It seems that I could create handlers in these files, that I could used. They are quite similiar in nature, seems to me most of functions are visible to all CView/CDoc/Mainfrm? Anyone care to share what's the different between these files?
|
|
|
|
|
Document hold document data
Main Frame is the main applications window
Views are windows which display the documents data and are children of the Main Frame.
I am assuming that by 'handlers' you are reffering to message handlers.
You have two options: either put your handlers in your Main Frame, or put your handlers in your View. Very rarely will you need to add handlers to your Document since it does not make too much sense.
In reality you will be putting handlers in both your mainframe and your views. Do you want your handler to work in every view or in only one type of view (this is only applicable when you have multiple views, i.e. MDI application). If you want a 'global' handler then add it to your main frame, if you want a 'local' handler (local to a view type), then add the handler to your view.
Also consider the type of access you need in your handler. If you need access to the Document data for example, it will be easier to put your handler inside your view since access to the document from a view is easier than from the main frame. This applies mostly to MDI applications. (SDI applications are much simpler since you can assume only one document, thus making it easier to locate from the mainframe)
In summery, treat every handler differently. Think about what the handler will be used for (logically) so that you can decide whether it should be a 'global' or 'local' handler. Think about the access requirements (do you need access to the document? Do you need access to the MainFrame?). One final tip: Observe and learn the code which ClassWizard generates so that you can modify it and move it around if neccessary.
James Pullicino
Drinking In The Sun
Forgot Password?
|
|
|
|
|
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
|
|
|
|