|
A CFormView (sorry - I gave the wrong class name in the previous post) is
"essentially a view that contains controls.
These controls are laid out based on a dialog-template resource."
<small>(from the MSDN entry <code>CFormView</code>)</small>.
You insert it with the wizard into your project. Place a CTreeCtrl on it.
Now your program should compile and link and the view shows an empty tree.
If you resize the tree, it will probably fill only parts of the view or the view will show scroll bars.
In your View class, override the handler for the message WM_SIZE to resize the TreeCtrl to the entire pane. That does mean, in your OnSize()-function, you call m_TreeCtrl.MoveWnd() with the new dimensions as received as parameters.
Now the TreeCtrl should follow the resizing of your View.
As the last step you can replace the CTreeCtrl with your own derived class. That is done without wizard help, simply by find-and-replace. If you miss one CTreeCtrl, you will get all sorts of funny errors. Just go around and replace the missing CTreeCtrl-occurences in your code.
Sorry if this sounds much, but it is not. The only thing that could be tricky is the OnSize() thing. Try it, and ask here again!
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Isn't the correct function MoveWindow?
How do I get the coordinates of the window into the RECT object. I forgot how to do that!
void CSacmanEditorView::OnSize(UINT nType, int cx, int cy) <br />
{<br />
CFormView::OnSize(nType, cx, cy);<br />
RECT window;<br />
<br />
this->m_ctrlEditorTree.MoveWindow(window);<br />
}
|
|
|
|
|
For getting the coordinates of the View you use GetParent()->GetClientRect(). (The Parent should be the View-pane).
I forgot whether you have to convert that with ClientToScreen().
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Hi, i need to close another applications receiving UDP socket. How would i do this? Do i need to use API hooking to hook the receive function??? or is there an easier way to close a UDP socket and stop the transfer of data??
Please help me, it is for a good purpose (an anti-crash)..
Kuniva
--------------------------------------------
|
|
|
|
|
Is it possible to make another applications TCP socket send some data as if the application sent it itself (so that for example, the sequence numbers would still be correct afterwards)?
Kuniva
--------------------------------------------
|
|
|
|
|
I don't know if an other app can do that, but a hook sure can . I don't know how to close sockets, not my field, sorry..
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
A question for the Thai programmers among us. I am after the MFC language resources that reside in the l.* directories, for building an application in Thai.
I would be most grateful if someone could point me in the right direction. I have searched the MSDN CDs we have here at work, but to no avail.
Happy programming!!
|
|
|
|
|
Just use Visual C++.NET.
Visual C++.Net (2002 or later) already support Thai Language. For Visual C++ 6.0, you need to buy a Thai version of Visual C++ 6.0 IF available I guess or probably Microsoft had provided a language pack.
To change to Thai version of RC (codepage) in Visual C++.Net. Just right click on your resource in the resource tab for eg. your dialog and change the language setting.
To learn to program your application in Thai. Just look for UNICODE string handling routines and tutorials which are available in CodeProjects.
Hope this helps.
|
|
|
|
|
Some time ago I built an application that contained English, Chinese Trad., and Chinese Simp. resources and it worked well in Chinese on the relevant insallation of Windows. I have now come across a problem that on XP it doesn't work. It is always in English, even when XP is rebooted in chinese, the keyboard is in chinese mode and SetThreadLocale is called in the InitInstance of the App.
Does anyone have any ideas on where the problem lies?
Happy programming!!
|
|
|
|
|
I am writing a dll that can open a process and place it in a job. I need to be able to change the limits of the job and\or add new ones after I have set them (I set the limits by calling SetInformationJobObject).
I have tried using QueryInformationJobObject() to fill a structure with the current limits and then add one limit to the existing structure. However, when I call "SetInformationJobObject" again, I overwrite the current limits that are set (Do I have to re-set each bit using LimitFlags everytime I want to change or add a limit)
Can I change the limits on a job after I have set them. If so, when can I do it so that it will apply to the processes that are in the job and the process that I am placing in the job, and do I have to set each restriction bit (using LimitFlags) for every restriction everytime i want to change to limits. If this explanation is hard to read, please let me know so that I can modify it...Any and all help is greatly appreciated....thanks
|
|
|
|
|
I create modelles dialog box as child inside a window
(not using MFC) tab navigation between controls does not work
is there some way to implement it ?
Thanks.
|
|
|
|
|
I had the problem with a modeless dialog owned by an ActiveX main window. Using MFC, I solved this by implementing in the PreTranslateMessage method of the Main Window the following code:
<br />
if((pMsg->message == WM_KEYDOWN) && (::IsWindow(pMsg->hwnd))){<br />
HWND hMsgWnd = pMsg->hwnd;<br />
HWND hParent = ::GetParent(hMsgWnd);<br />
<br />
if(hParent){<br />
if((pMsg->wParam == VK_TAB) || (pMsg->wParam == VK_RETURN)){<br />
if(CWnd::FromHandle(hMsgWnd)->PreTranslateMessage(pMsg))<br />
return TRUE;<br />
else <br />
if(pMsg->wParam == VK_TAB){<br />
BOOL bShift = HIBYTE(GetKeyState(VK_SHIFT));<br />
HWND hNewWnd = ::GetNextDlgTabItem(hParent, hMsgWnd, bShift);<br />
if(hNewWnd){<br />
TCHAR szClass[10];<br />
HWND hFirstWnd = hNewWnd;<br />
BOOL bBreak = FALSE;<br />
while(::GetClassName(hNewWnd, szClass, 10) && (lstrcmpi(szClass, _T("STATIC")) == 0)){<br />
HWND hOldWnd = hNewWnd;<br />
hNewWnd = ::GetNextDlgTabItem(hParent, hNewWnd, bShift);<br />
if(hNewWnd == hOldWnd){<br />
hNewWnd = NULL;<br />
break;<br />
}<br />
if(bBreak){ <br />
hNewWnd = NULL;<br />
break;<br />
}<br />
bBreak = (hNewWnd == hFirstWnd);<br />
}<br />
if(hNewWnd){<br />
::SetFocus(hNewWnd);<br />
return TRUE;<br />
}<br />
}<br />
}else{<br />
if(pMsg->wParam == VK_RETURN){<br />
TCHAR szClass[10];<br />
<br />
if(::GetClassName(hMsgWnd, szClass, 10) && (lstrcmpi(szClass, _T("BUTTON")) == 0)){<br />
::SendMessage(hParent, WM_COMMAND, ::GetDlgCtrlID(hMsgWnd), (LPARAM)hMsgWnd);<br />
return TRUE;<br />
}<br />
}<br />
}<br />
<br />
return CWnd::FromHandle(hParent)->PreTranslateMessage(pMsg);<br />
}<br />
if(CWnd::FromHandle(hParent)->PreTranslateMessage(pMsg))<br />
return TRUE;<br />
}<br />
}<br />
We do not inherit the Earth from our ancestors, we borrow it from our children - Antoine de Saint-Exupéry (1900-1944)
|
|
|
|
|
|
My pleasure
We do not inherit the Earth from our ancestors, we borrow it from our children - Antoine de Saint-Exupéry (1900-1944)
|
|
|
|
|
Hi, I am new here and I am very impressed with the level of skill I have seen in the articles, so I am very hopefull that someone can tell me where I am going wrong.
I have a Dialog based app.
in the main dialog header file I have declared a function
UINT Recieve(LPVOID pParam);
In the cpp file I try to start a worker thread like this
AfxBeginThread(Recieve);
I get a compiler error
error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'
The documentation says
The controlling function defines the thread. When this function is entered, the thread starts, and when it exits, the thread terminates. This function should have the following prototype:
UINT MyControllingFunction( LPVOID pParam );
and my code follows the example exactly.
Anyone konow where I am screwing up?
|
|
|
|
|
Does it give the type it is expecting?
9ball wrote:
error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)' to type ???
|
|
|
|
|
No. I copied the error message directly from the output window and put it in the message.
I created the app with app wizard.
these are the include files
#include "afxwin.h" // MFC core and standard components
#include "afxext.h" // MFC extensions
#include "afxdisp.h" // MFC Automation classes
#include "afxdtctl.h" // MFC support for Internet Explorer 4 Common Controls
#include "winsock2.h"
#include "process.h"
I added winsock2.h and process.h, and I have no other classes.
|
|
|
|
|
I declared Recieve as static and that did it, thanks a lot for the help, I knew I came to the right place
|
|
|
|
|
AfxBeginThread requires 2 paramaters, a function pointer and an LPVOID which is usually a pointer to the instance of the class that calls the thread. Also, your thread function should be declared static as well. Then you would spawn the thread like:
AfxBeginThread(Recieve, this);
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
I just tested your code by placing the Recieve function within a clas and get that exact error message. You need to define the function as static if you're going to use a member function as the first parameter of all instance functions is the this pointer.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Although I don't totally understand how this works, here is a sample of the code that I'm using.
// Declared in the header file.
bool StartReminder();<br />
static UINT ThreadForReminder(LPVOID pParam);
// When a user presses the remind me button I spin my //thread.
void CConstantReminderDlg::OnRemindMeButton() <br />
{<br />
<br />
if(!this->GetThreadIsSpinning())<br />
this->SpinThread();<br />
}<br />
}
UINT CConstantReminderDlg::ThreadForReminder(LPVOID pParam)<br />
{<br />
UINT returnCode = 0;<br />
CConstantReminderDlg* pObject = (CConstantReminderDlg*)pParam;<br />
<br />
if (pObject == NULL)<br />
return 1;
<br />
pObject->StartReminder();<br />
return 0;
}
void CConstantReminderDlg::SpinThread()<br />
{<br />
this->SetThreadIsSpinning(true);<br />
<br />
::AfxBeginThread(ThreadForReminder,this);<br />
}
// The user has requested the program begin and the thread // for reminder dialog has been spun.
bool CConstantReminderDlg::StartReminder()<br />
{<br />
<br />
CEvent wakeUpTimer(false,false,"probeDroid",NULL);<br />
HANDLE hHandle = (HANDLE)wakeUpTimer;<br />
COleDateTime timeStart,timeNext;<br />
<br />
this->SetUserWantsToQuit(false);<br />
<br />
|
|
|
|
|
Send me your email (tarcher@mindspring.com) and I'll send you a very simple example of using AfxBeginThread. You can then compare, discern what you're doing wrong and post what you find here for anyone else that runs into the same problem.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
I have to create a dialog box where i will get the values for the X and Y coordinates and then pitch of the rows and columns. taking these values i have to create a kind of a grid which shows the pattern in which holes will be drilled in a machine. whether a hole is drilled or not will depend upon the bit pattern entered by the user 1 for hole and 0 for none.
i have to convert this in an ascii format and display it.
Any ideas on how to do it? I just know the V of Visual C++ and i am stuck.
Every problem has a solution!
|
|
|
|
|
you mean converting int to readable ascii??
char buffer[256];
sprintf( buffer, "%i", iInt );
...
sprintf required stdio.h, wsprintf is the windows api equivalent
Don't try it, just do it!
|
|
|
|
|
Hi I'm new to C++ programming, I would like to know if the below information could be done? If so, how and what would the coding look like?
C++ Dive Log Page Program:
Create a class DiveLogPage, along with a main routine to create & manipulate instances of DiveLogPage (manipulating them enough to “prove” that the class works properly) Provide the following member functions: constructor function ( with dialog, as described below), >><<, and displayDiveLogPage. Note that >> and << should be “symmetrical” (i.e. you should be able to read back what was written). The displayDiveLogPage member function should do a “pretty / reasonable” display of the DiveLogPage (i.e., display the various data members on the screen with headers).
A dive log consists of an entry for each dive that diver has made. Our dive log entries (i.e.., our DiveLogPage) will consist of the following items: dive number, start time, stop time, bottom time, average depth, maximum depth, starting tank pressure, and ending tank pressure. Data types for these items are shown in the table below.
integer dive number, average depth, maximum depth, starting tank pressure, ending tank pressure
Time start time, stop time, bottom time
The DiveLogPage constructor function should begin a dialog to get “most” of the items from the user( i.e.., user input prompts and input statement) Get the following items directly from the user: start time, stop time, average depth, maximum depth, starting tank pressure, and ending tank pressure. Data validation is required as follow: stop time > start time, maximum depth >= average depth, ending tank pressure < starting tank pressure. You should then calculate the bottom time (as stop time-start time). The class should maintain a static variable to set the dive number for the user (i.e.., first dive entered is dive number 1, second dive entered is dive number 2, etc...). Note that when reading a dive log from a file you must make sure that dive number is properly set as the user may create more DiveLogPages.
Create an array of 5 DiveLogPages. The main routine should be menu-driven, giving the user the following options:
0: quit
1: make an entry in the dive log
2: correct an entry it the dive log
3: display the current dive log
4: write the current dive log to file
5: read a dive log from a file
The “correct an entry in the dive log” option should first get the dive number for the entry that the user wants to change, and then display the following menu:
0: done making changes
1: change start time
2: change stop time
3: change average depth
4: change maximum depth
5: change starting tank pressure
6: change ending tank pressure
Instead of an array of 5 DiveLogPages, use dynamic allocation to allow user to create as many DiveLogPages as they want.
Divers generally store text information as well as numeric. Add 2 fields: dive site and dive notes. Dive sites should store up to 25 characters (including blanks), and notes should store up to 100 characters (including blanks). Get these values from the user as part of the constructor function dialog. Include options to correct the fields (under “correct an entry in the dive log”), but you only need to allow the user to replace them, not edit them.
C++ Newbie
|
|
|
|
|