|
Hi there !
I made a few searches through the articles and through the board, but didn't manage to find an answer.. If there is already an answer to this, just post the link
So, I have a CCtrlView-derived class, CTabView (No, not a co-incidence). This class is responsible for upkeeping a Tab control (Created through CCtrlView's constructor) and an array of CViews. Now, when you wish to add a new view to the tab, it requires you to insert a pointer to your CView-derived class through the RUNTIME_CLASS-macro. After that, it checks if the run-time info you specified is indeed a CView-derived, and creates a new object based on this info with CRuntimeClass::CreateObject.
When the creation is done, it creates and attaches a new view to this object by casting a pointer to the CView-class and calling it's Create-method. Then, it saves the CView-pointer to a CObList for further use.
When quitting, the application goes through the list and calls each CView's DestroyWindow in succession until the list is clear. After that, it posts a OnDestroy-message to the underlying CCtrlView which destroys the tab control.
But the problem is that when I build & run this app, it works smoothly until the quit phase. There, it causes an assertion. What am I missing here ? Should I use 'delete' on each of the pointers after DestroyWindow as well ? Can it be done ? What, exactly, does CreateObject do when it builds an object from the run-time info ? And if 'delete' is not the answer, what is ?
Or shouldn't I delete the views at all, but let "The Framework" work it out ?
Of course, if someone already has a functioning Tab control which accomplishes the above mentioned smoothly, a link is again appreciated
Thanks in advance,
Antti Keskinen
EDIT: The 'delete' operation did no good, the app still asserts. For additional info, I am using a splitter window to where my derived control view is loaded to. Debugging reveals it is XTreme toolkit's CXTPFrameWnd, which causes the assertion.
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
hello, i am new to MFC, and i am trying to implement a very simple Timer it does not work.. i create the most basic MFC project with the wizards, code is like this:
in MainFrm.cpp
----------------
void CMainFrame::OnStartTimer ()
{
mTimer = SetTimer (1,1000,0); //1 sn intervals
}
void CMainFrame::OnTimer (UINT_PTR ptr)
{
MessageBeep (MB_ICONEXCLAMATION); //make a sound
}
in MainFrm.h
----------------
...
public:
void OnStartTimer(void);
...
protected:
afx_msg void OnTimer (UINT_PTR);
....
i try to call the OnStartTimer from the project.cpp file after the creation and painting of the MainFrm object, indeed it goes to the OnStartTiner() function but system never calls the OnTimer function. what i am doing wrong?
(i use VC++ in Studio.Net 2003)
Thanks.
|
|
|
|
|
Go check your 'MainFrm.cpp'. In the top of it, locate a 'BEGIN_MESSAGE_MAP' - 'END_MESSAGE_MAP' pair. Between these two lines, look for 'ON_WM_TIMER ()' entry.
If this entry doesn't exist, add it manually between the linepairs, so that your code looks like this:
<br />
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)<br />
....<br />
ON_WM_TIMER ()<br />
...<br />
END_MESSAGE_MAP()<br />
The '...' mean other entries in the message map. Do not modify these, if there are any. Just add an empty line and write your new entry there.
Now, whenever a WM_TIMER -event occurs, the function 'OnTimer' gets called.
If the timer still refuses to co-operate, start Microsoft Spy and look for messages sent to your application when it is running. If you don't see the 'WM_TIMER' messages popping in there regularly, then your SetTimer-function fails to create a timer. If it displays 'WM_TIMER' messages, then see below.
Remember to add the 'KillTimer' function call to the end of your application. If you leave the timer ticking after your window is destroyed (done by the Framework), future timers may behave incorrectly. A reboot helps remove unwanted timers if they've been left.
Greetings from,
Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks a lot fo the help! very clear and detailed answer!
|
|
|
|
|
Hi,
How do I access a Global variable of one Dialog box from a another one.Some suggested sending messages, but how do I send a variable using sendmessage? anone line example would be great.
Thanks
Deepak Samuel
|
|
|
|
|
One solution is to send a pointer. Another solution is to declare the global variable using extern inside, for example, stdafx.h.
Kuphryn
|
|
|
|
|
If the second dialog box is modal, then you can add a variable fo the same type as the global variable in your dialog's header file - in the public: section.
Then when you instantiate your second dialog box, you can assign the value of that dialog's variable:
CMyDialog dlg;
dlg.TheLocalVariableIWantToBeTheSameAsTheGlobalVariable = GlobalVariableValue;
dlg.DoModal();
|
|
|
|
|
In Fact the simplest way to do this is to have a parent class handle the variable so that both dialogs can access the variable, regardless if they are modal or modeless dialogs. For example if both dialogs are displayed from a handler in the MainFrame class, have the mainframe class contain the variable, make the variable public (or better still add functions to get and set the variable), then pass this into the dialog classes when they are created, then either dialog can call GetParent()->(variable name) or GetParent()->(function name).
As an alternative to this you can make a third class that is soley used for holding data (e.g. not a display class), this could then hold the data to change, and both dialogs could hold a pointer to this class and then they can access the variables and functions of that class.
Mark.
|
|
|
|
|
Hello,
how can I create a Folder (for example: "MyPersonalFolder") under an existing Folder such as "Inbox".
Actually I can create a folder on the same rank as for example the "inbox".
Thanks a lot for helping me !
|
|
|
|
|
I am cleaning up my code a little bit and put the window procedure of a subclassed list box into a class but when I get the following compire error when calling SetWindowLong:
<br />
cSkinListObject.DefSkinListProc = (WNDPROC) GetWindowLong(hwndSkinList, GWL_WNDPROC);<br />
SetWindowLong(hwndSkinList, GWL_WNDPROC, (LONG) cSkinListObject.SkinListProc);<br />
<br />
error C2440: 'type cast' : cannot convert from 'long (__stdcall cSkinList::*)(struct HWND__ *,unsigned int,unsigned int,long)' to 'long'<br />
Where as if it is not in a class it casts fine...how to cast this properly?
|
|
|
|
|
A member function can't be a callback because of the implicit this parameter. Your options are use a global function or a static member function (which has no this ).
--Mike--
Ericahist [updated Oct 26] | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain."
-- Paul Watson, Linux Zombie
|
|
|
|
|
Is there any way to display all the processes/applications which install Keyboard hook in windows.
|
|
|
|
|
Install a system wide WH_DEBUG hook then press a key?
(Not so sure about this as I haven't done it but I think it should give you the list?)
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Can I close all the processes by using that process list.
|
|
|
|
|
from where can i get shlobj.h for version 5.0 of shell32.dll
its urgent
modified 21-Apr-21 21:01pm.
|
|
|
|
|
|
i already have visual studio 6. do i have to download the sdk again?
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Yes. The Platform SDK is a separate entity.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hello, everyone!
I have tried this sample on both Windows 2000 Professional and Windows 2000 Server, both works perfectly when monitering:
Network Interface --> Bytes Total/sec of [My network adapter]
But it does not run properly on Windows XP system. When monitering the above performance parameter of my XP machine, I can not get the bandwidth value output.
Here is the URL link of this sample,
URL Link:
----------
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/base/browsing_performance_counters.asp
----------
Can anyone help?
Thanks in advance,
Geo
|
|
|
|
|
Hi, everybody, there is a article at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/creating_a_child_process_with_redirected_input_and_output.asp
I built the sample code into two programs: a parent process and a child process named child.exe. When I test it, it is sure the child process's output can write to the parent process's console. However, I seemed to be impossible for the child to read from the parent. Anyone who is interested can try it. Since it is put on the Ms's website......, I can not imagine there is a bug so prominent!
any advice by Gurus?
|
|
|
|
|
u need to create 2 pipes.
the pipe from parent to child is OK according to ur question.
create another one similar to this one from child to parent.
includeh10
|
|
|
|
|
Hi,
I have a button, which on clicking pops up a new dialog box. When I click the button once more the dialog box is created once more. i want to avoid this. I want the dialog box to be created only once, and if the button is clicked while its popped up , i dont want to be created. I just want only one instance of it .what should I do,
Thanks in advance
Deepak Samuel
|
|
|
|
|
Hi there,
there are several ways to avoid this
1 Can keep a Flag and check if it is set dont open the dialog box again,
2.If u can make ur dialog box class singleton it will solve ur prob !!
3. u Can also use Mutex to avoid this .
4. And dear u can also achieve this by making ur dialog box Modal instead of modeless...then no one can ever be able to click that dam'n button again
Abhishek Srivastava
Software Engg (VC++)
India ,Noida
Mobile no 9891492921
|
|
|
|
|
Thanks a lot four your kind suggestions..
Deepak Samuel.
|
|
|
|
|
I have a edit box, where i need to type in comments.There is also a ok button. my problem is that when i want to go to the next line in the edit box,I press enter (which is the usual procedure in MS word or applications like that) but it does not go to the next line , rather it reacts as if I pressed the ok button.What should I do in order to go to the next line in the edit box as soon as i press enter?
Thanks
Deepak Samuel
|
|
|
|