|
Correct me if I am wrong, but I always thought, that the dlls have they own heap - therefore if you malloc something in DLL you are not able to free it in the EXE (or another DLL). I am not really sure about that, but it was told me in some years ago, while learning working with DLLs I allocated some resource in DLL1 and tried to free it in DLL2, getting the heap corruption message.
|
|
|
|
|
Hello Everybody,
Is there a way to put text in a dialog that the user can click and load a IE window with the URL? I tried a couple of things and nothing works. Any suggestions? Any answer is more than welcome.
Best regards,
Luis E. Cuadrado
)
|
|
|
|
|
|
One solution is ShellExecute()
ShellExecute(// Handle to window of new process.
NULL,
// Command
TEXT("open"),
// Source data
"???.???.???/???.???"
// New process paramater
NULL,
// Directory
NULL,
// Window
SW_SHOWNORMAL);
Kuphryn
|
|
|
|
|
If Ido:
BOOL ret = pImageDisplay->Create(IDD_IMAGEDISPLAY, this);
pImageDisplay->m_zoomFactor = 500;
pImageDisplay->ShowWindow(SW_SHOW);
pImageDisplayVector.push_back(pImageDisplay);
}
THe images in the modeless dialog get the info about the zoomfactor.
But........ If I pull the pointer off the vector and do this (show the window here instead):
loop through the vector:
{
pImageDisplayVector[i]->m_zoomFactor = 500
pImageDisplayVector[i]->ShowWindow(SW_SHOW);
the dialog doesnt get any zoom info.....
I'm doing something dumb? Missing something really obvious?
Appreciate your help,
ns
|
|
|
|
|
If it's a pointer then it should work both ways. What is in the vector, a CWnd derived class ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
There just isn't enough information there. It looks like it should work, but there could be 100000 other things going on.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
in the second approach r u still creating it/them pImageDisplay->Create(IDD_IMAGEDISPLAY, this);
?
-pete
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
Yes, I create them. push_back them in one function. then, retrieve them in another function..
Another thing....I'm trying to figure out by putting in breakpoints the sequence of events. Basically I'm going to restore the Cdialogs spawned by my view using the registry. Each CDialog has a magnification member . So if the registry says there were cdialogs spawned last time, I create the cdialogs in initial update after seeing how many there were the last time it ran. Then I call another function so I dont clutter things, and in that I was going along looping and assigning the magnification saved in the regsitry to the dialogs via pointers from the vector. Finally i did showwindow on them (in this separate fuunction).
The way it looks now is that I'll have to quiz my registry for the magnification info in a function which I had wanted to dedicate only to create the CDialogsvector. ....
But I'll look some more into it befoore I spaghettify things....
Thanks everyone!
|
|
|
|
|
I have a Single Doc app. I the apps InitInstance, the program does several things, one is finding out how to configure the menus and configuring them. The top level ones work fine, File, Edit, Help - i can gray them out and enable them if I wish. But the submenues blow up the program when they go to open. I'll move to a disabled item, and click it (nothign happens of course) I move to a non-disabled one (but one who'se contents I've modified) and I get an assert. I don't have any numm handles or pointers though.
Also I am having a problem updating the screen. I can all RedrawWindow wit the RDW_FRAME flag and the menu looks corrcectly, but it erases everything in my Doc view!
Many thanks in advance!
|
|
|
|
|
It sounds like a problem of managment of graphic objects, as fonts, brushs or pens.
The first rule with these objects is to always release them before destroying the device context using these objects
I suppose its located in your view. When you open a submenu, it hides a small part of the view, which is redrawn when the submenu is closed.
Where is the assert?
Angels banished from heaven have no choice but to become demons
Cowboy Bebop
|
|
|
|
|
Ok, here is the line I am using in my CWinApp derived app, in the InitInstance, (AFTER the CSingleDocTemplate has loaded specifying the menu (IDR_MAINFRAME) AND after Show() has been called)
[ccode]
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CWinAppDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CWinAppView));
AddDocTemplate(pDocTemplate);
... code to determine that some menu items are to be disabled ...
m_pMainWnd->GetMenu()->GetSubMenu(0)->EnableMenuItem(i, MF_BYPOSITION|MF_GRAYED);
[/ccode]
That line 'works', but when I try to exand SubMenu 0 ('File') it blows up here:
[ccode]
_AFXWIN_INLINE UINT CMenu::GetMenuItemCount() const
{ ASSERT(::IsMenu(m_hMenu)); return ::GetMenuItemCount(m_hMenu); }
[/ccode]
Which is being called from: CFrameWnd::OnInitMenuPopup(CMenu * 0x00bf6b80 {CTempMenu}, unsigned int 0, int 0)
I think it's because the menu hasn't been init'ed but the calls to modify the menu don't fail.
|
|
|
|
|
Ok, I thin I've understood. It's not the good way to set menu item sensitivity. MFC framework uses another system, the "OnUpdateUI" mechanism.
Basically:
In the MainFrame (or View, as you wish) message map, add
ON_UPDATE_COMMAND_UI(ID_MYMENUCOMMAND, OnUpdateMyMenu)
Next, add the method
void CMainFrame::OnUpdateMyMenu(CCmdUI* pCmdUI)<br />
{<br />
pCmdUI->Enable(FALSE);
}
It's possible to do this using the ClassWizard.
You may find useful info on this mechanism on
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_ccmdui.asp
HTH,
K.
Angels banished from heaven have no choice but to become demons
Cowboy Bebop
|
|
|
|
|
Thank you...
But so you're saying for each one [menu item] I have to create an entry and write a function?
Wow.
Thanks again.
|
|
|
|
|
There is a possibility to affect a method to a range of Ids, using the macro ON_UPDATE_COMMAND_UI_RANGE
(also, by default, menu items which have an associated command are enabled, menu items without command are disabled)
But mainly, yes, you have to. However, classWizard makes the task easier.
Angels banished from heaven have no choice but to become demons
Cowboy Bebop
|
|
|
|
|
hi,
i get this same error.
And i have done
ON_UPDATE_COMMAND_UI(ID_MYMENUCOMMAND, OnUpdateMyMenu)<br />
(and)<br />
void CMainFrame::OnUpdateMyMenu(CCmdUI* pCmdUI)<br />
{<br />
pCmdUI->Enable(FALSE);
}<br /> for one of my submenu's (with handler for the commands of all menuitems) which gets executed.
However, i still get this error.
ps: when doing e.g. GetMenuItemCount() it works; but after doing myMenu.Detach(); it doesn't work anymore (like in the assert error on GetMenuItemCount as stated by Anonymous)
|
|
|
|
|
|
i read it and i think i understand the updating of the menuitems.
But i am still having my assert error..
?
|
|
|
|
|
I want to create some 'Global' flag (expalantion...):
Iv'e tried the kernel sync objs but I can't query it with 'IsLocked' kind of functions (no such???)
They must support naming, have boolean behaviour - means that they can be queried and set with true/false values (or 'valid addrr'/'NULL'), must be accessable from any process/thread, mustn't be physicals (like files).
Is there someone with an answer or am I going CRaZzZzY?!?!?!
Thanks gals...
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
can u specify why/how the mutex does not solve ur problem?
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
I don't need any kind of a waitable lock. On a mutex I can't ask 'IsLocked' and get an ansewer right away without waiting. I only want a 'flag' that I can 'set and get' ( True/False ) from any process/thread ( Naming is required for locating it of course ).
This comes any clearer? damn I hope so...
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
>> This comes any clearer?
no i'm afraid not.
>> I don't need any kind of a waitable lock
it sounds like u do from ur description:
>> I only want a 'flag' that I can 'set and get' ( True/False )
also
>> On a mutex I can't ask 'IsLocked' and get an ansewer right away without waiting.
not true
if( WAIT_TIMEOUT == WaitForSingleObject( mymutex, 0))
// it's not signaled
else
// it's signaled
-pete
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
Indeed, some kernel objects can be queried using WaitForSingleObject (events, semaphores, mutexes ...). Here's a sample that I didn't bother to build or test, but it should be pretty close to what you need:
class CSharableObject
{
public:
CSharableObject( const TCHAR * p_pszName ) :
c_hMutex( NULL )
{
c_hMutex = OpenMutex( SYNCHRONIZE, FALSE, p_pszName );
if( c_hMutex == NULL )
{
c_hMutex = CreateMutex( NULL, FALSE, p_pszName );
if( c_hMutex == NULL )
{
}
}
}
~CSharableObject()
{
if( c_hMutex != NULL )
{
CloseHandle( c_hMutex );
c_hMutex = NULL;
}
}
bool IsLocked()
{
DWORD a_dwReason = WaitForSingleObject( c_hMutex, 0 );
if( a_dwReason == WAIT_TIMEOUT )
return true;
return false;
}
unsigned long Lock( unsigned long p_ulTimeout = INFINITE )
{
return WaitForSingleObject( c_hMutex, p_ulTimeout );
}
bool Unlock()
{
return ReleaseMutex( c_hMutex ) != 0;
}
protected:
HANDLE c_hMutex;
};
Now, whereever you need to use the shared resource:
CSharableObject a_oLocker( _T("SomeUniqueName") );
a_oLocker.Lock();
a_oLocker.Unlock();
if( !a_oLocker.IsLocked() )
{
}
else
{
}
It would be a good idea to make this more robust etc, but it's a start.
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
Is there a way to add a menu to a dialog based application? I could start over again with a Single Document design, but if there's a relatively simple way to add a menu to my existing dialog based app, it would be the least painful for me.
Thanks.
|
|
|
|
|