|
blackbolek wrote: ((CMonitorDlg*)m_pWnd)->SendMsg(unit, "MO", grpcmd);
The application crashes at this moment with Access Violation error.
Are you sure that m_pWnd is a CMonitorDlg ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Here is my declaration of m_pWnd for GroupStart class:
<br />
private:<br />
CDialog* m_pWnd;<br />
When I change it for:
<br />
private:<br />
CMonitorDlg* m_pWnd;<br />
it's still the same error in the same place. So it doesn't change anything.
m_pWnd is not 'initialized' anywhere. How should I initialize it?
modified on Tuesday, December 15, 2009 10:37 AM
|
|
|
|
|
blackbolek wrote: It's not 'initialized' anywhere. How should I initialize it?
I think you should really learn a bit more about the concept of classes in C++. This is really basic C++ stuff.
You have to pass an instance of your dialog to the GroupStart class (but instead of the generic CDialog, use a pointer to a CMonitorDlg instead, this way you won't need to cast). This is typically done in the constructor: you add an additional parameter in the constructor of GroupStart (and when you conctruct it from CMonitorDlg, you simply pass the this pointer).
|
|
|
|
|
Yes - that sorted the problem.
Thank you very much for your help.
|
|
|
|
|
In addition to Devaid's answer, how did you initialize m_pWnd ? Are you sure it is not null ?
|
|
|
|
|
I am Having a Virtual List Control,with 5 columns.if i double clock on the first column i want to sort the list by that column,& if i clicked on second column i want to sort it by that column & till the last column. how i can accomplish this.Can i get a simple example of this
|
|
|
|
|
As far as i know virtual list controls do not provide you with any means of sorting, you have to do it yourself. If the user clicks a column header you get a LVN_COLUMNCLICK[^] notification from your list control (i don't know about doubleclick, look around List View[^] in MSDN), upon this message you should/need to sort your data yourself (using some nice sorting algorithm like Quick-sort[^]) and then redraw the list items. Good luck.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
hi all,
Actaully my Question seems to be silly but i just wanted to know can i set the same key accelerators to two ID's i.e if i have popup menu lock and unlock a object than if my accelerator is Ctrl+L then on first press of Ctrl+L it should lock object and agian on second time keypress it should unlock it... for lock and unlock the id's are different
Thanks
Samir
|
|
|
|
|
Hi Samir! Assign Ctrl+L to ID_APP_OBJECT_TOGGLE , and write a command handler that toggles the object (lock/unlock object depending on current state). Does that work for you?
Hope it helps.
/M
|
|
|
|
|
write a function ChangeLock() of your object
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
You could have 2 accelerator tables, one for lock and one for unlock assigned to Ctrl+L and swap between them when needed, or if you create the accelerator table programatically using CreateAcceleratorTable[^] then you could re-create the table with the new key-command assignments as needed, but i doubt you want to go thorough this trouble to implement an ugly solution. You are probably better off assigning a third command to Ctrl+L whose handler will toggle/negate the current state as someone already suggested.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I have an ocx (in visual studio 6, lets call in main ocx) which includes in it a pointer to another ocx (which was written in visual studio 2005, lets call it sub ocx). the main ocx (in Visual Studio 6) has a wrapper for the second ocx which was created by "project->add to project->components and controls", the wrapper is 1 *.cpp file and one *.h file.
In the code in the main ocx, I call "psub = new sub()", and after that I call psub->create(...).
inside create I get crush in file OCCCONT.CPP, at function "BOOL CWnd::InitControlContainer()" at line "m_pCtrlCont = afxOccManager->CreateContainer(this);"
In sub::InitInstance() I call AfxEnableControlContainer() and also in main::InitInstance() I call AfxEnableControlContainer(), as I've read in the internet while I was trying to figure out the problem, but I still get crush.
This is the place to mention that the place where I call "psub = new sub()" and then "psub->create(...)" is inside a static thread. I must keep this call inside the static thread.
In addition, I see that the psub->m_hWnd before psub->create(...) is null.
Does anyone have any idea what to do?
Thanks
Miriam
|
|
|
|
|
you better use the same Version of Visual Studio for all OCX for compatibility.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
but the sub ocx uses webservice which is supported only in VS 2005, and the rest of the code, (which is huge projects, milions of code-lines) is in VS 6.
Do you have any other idea?
Thanks
|
|
|
|
|
Finding the crash course, looks like you need a HWND and havent a valid one. -> Create a Window.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
you mean creating a window in the sub ocx or the main one?
or it doesn't matter..
Thanks
modified on Tuesday, December 15, 2009 7:44 AM
|
|
|
|
|
for solving your writing: "I see that the psub->m_hWnd before psub->create(...) is null."
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Hi.
I created a window in the sub ocx and added this method to the wrapper (please remember that the main ocx calls the sub ocx's methods by invoke helper (it is created inside the wrapper)).
now, after i call new sub() and before I call psub->create(...) , I call the new mthod that creates the sub window. When I call that method, the invoke helper crushes in WINOCC.CPP function CWnd::InvokeHelper at line
" ASSERT(m_pCtrlSite != NULL); // not an OLE control (not yet, at least) "
I don't understand why.
I checked the sub ocx and that new function of it and it works fine as stand alone but when I have the wrapper between it, it crushes there (where I mentioned).
I serached in the internet and saw that most of the solutions for this problem is calling DoModal function but the ocx is not dialog based (the wrapper was build ,thought, through dialog based dll and I copied the wrapper into my project).
I would appreciate any help
Thanks
|
|
|
|
|
Hi all...
I have a third party OCX , which i want to use in my application.
Can someone help me out , how to do this.
I have never done any such stuff , but i know VC++ a bit.
Also tried to search on net but no useful help is there.
It'll be really helpful if i can get any help from you guys.
It's not enough to be the best, when you have capability to be great....
|
|
|
|
|
If you're using MFC then, on Visual Studio, select the Project->Add Class menu item and (in the newly appeared window) choose MFC Class From ActiveX Control .
It will allow you to browse for the .OCX file (or select it form the ones in the registry) and finally will generate the MFC wrapper class.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
You are welcome.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
HI all,
i m inserting number of items in list control,here the vertical scroll bar automatically displayed when items are more than its height.
i want to move vertically down the scroll bar while inserting value,to know what value is inserted now.
please tell me how can i do this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Hi,
See CListCtrl::EnsureVisible[^]. You should ensure that the last item in the control is visible with this call. And that will automatically scroll down if needed.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
using EnsureVisible after inserting each item.
//i=item no.
m_List.EnsureVisible(i,FALSE);
but its not scroll down
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|