|
and don't forget to delete this in the PostNcDestroy notification in the modeless dialog
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
adding that gives me this error when i build & run:
Debug Assertion Failed!
Prgram :...\yadayadayada\myapp.exe
File: winocc.cpp
Line: 301
|
|
|
|
|
Instead of pdlg->Create(IDD_NOTEDLG,this);
try
pdlg->Create(CNoteDlg::IDD);
And check if (pdlg != NULL) .
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
well the code now looks like this and i still get that assert debug error and the window still doesnt show:
void CMyAppDlg::OnHitMe()
{
// TODO: Add your control notification handler code here
// Display the modal dialog box
pdlg = new CNoteDlg(this);
if (pdlg != NULL){
pdlg->Create(CNoteDlg::IDD);
pdlg->ShowWindow(SW_SHOW);
}
else
{
AfxMessageBox("Error");
}
}
however just recently i decided to try debugging, and i was looking through and i get an error of "this CXX0017:Error: symbol "this" not found
i appreciate your help
|
|
|
|
|
I'm sorry I don't know what's wrong with the code. That's an excerpt from the code from one of my apps:
playerDlg = new CPlayersDlg(this);
playerDlg->Create(CPlayersDlg::IDD);
if(playerDlg != NULL)
playerDlg->ShowWindow(SW_SHOW);
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi
Does anybody knows how can I remove the close, maximize and minimize buttons from a dialogduring runtime?
(I use the doc/view configuration in my project)
|
|
|
|
|
Use ModifyStyle() !
A. Riazi
|
|
|
|
|
You can use SetWindowLong.
SetWindowLong(this->m_hWnd,GWL_STYLE,
GetWindowLong(this->m_hWnd,GWL_STYLE) |
WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
That code would add the minimize and maximize box.
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
I want to create a simple window using MFC (non Doc/View app). I am using AfxRegisterWndClass() to create a window of my own class. Can anyone tell me that how can i change the name of my window class ???
|
|
|
|
|
|
how can i know if the sheet contains charts or graphs ??
I tried to call _Worksheet::ChartObjects(1) but I got error..
Can someone help me please.
my program is an excel automation.
thank you
|
|
|
|
|
Hi there,
I am searching a program which shows which files are used by my program. I know dependencytracker but it is a bit complicated for me. So is there a simple prog to find out? I am searching this to run my app in another machine...
Thanx for reading...
|
|
|
|
|
|
How can I determine CPU USage in WinXP?
|
|
|
|
|
CTRL-ALT-DEL -> Task Manager button -> Performance tab
|
|
|
|
|
|
Can someone tell me how to make my program switch between monitors, i.e. make a new monitor the active one? Also how do I split one monitor into two spaces, then swap between them. I would think all this is related. Splitting up the desktop, then activating a part of it.
chris
|
|
|
|
|
|
Can I block keyboard events such as keypress or key down of any key in a program?
The program will be controlled by a mouse only.
Thanks
JW
DJ
|
|
|
|
|
|
this program can be run at any time?
I customized media Player based on Windows Midia player control. However, the media player could not be run exclusively, that means if I try to run two of them, each one will open a media file and play simultaneously.
How can I program so that only one media player program can run at any time? Like using Windows MEdia Player, if you try to run a second movie file, the Media Player will close the first media file and turn to start running the second media file?
The platforms are VC++6 and WIndows 2000 Pro.
Appreciate your help!
JW
DJ
|
|
|
|
|
|
Excerpt from MSDN:
You will find this in the file msdn_mfcfaq50.htm (MFC FAQ).
---------------
How do I limit my MFC application to one instance?
Look at the Microsoft C++ sample ONETIME.
In brief:
const char* MyMainWndClassName = "MyMainWndXQW"
BOOL CMyApp::InitApplication()
{
// Call base class. Default version does nothing.
CWinApp::InitApplication();
WNDCLASS wndcls;
// Start with NULL defaults.
memset(&wndcls, 0, sizeof(WNDCLASS));
// Get class information for default window class.
::GetClassInfo(AfxGetInstanceHandle(),"AfxFrameOrView",&wndcls);
// Substitute unique class name for new class.
wndcls.lpszClassName = MyMainWndClassName;
// Register new class and return the result code.
return ::RegisterClass(&wndcls);
}
And:
BOOL CMyApp::FirstInstance()
{
CWnd *PrevCWnd, *ChildCWnd;
// Determine if another window with our class name exists.
PrevCWnd = CWnd::FindWindow(MyMainWndClassName, NULL);
if (PrevCWnd != NULL)
{
// If so, does it have any pop-ups?
ChildCWnd=PrevCWnd->GetLastActivePopup();
// Bring the main window to the top.
PrevCWnd->BringWindowToTop();
// If iconic, restore the main window.
if (PrevCWnd->IsIconic())
PrevCWnd->ShowWindow(SW_RESTORE);
// If there are pop-ups, bring them along too!
if (PrevCWnd != ChildCWnd)
ChildCWnd->BringWindowToTop();
// Return FALSE. This isn't the first instance
// and we are done activating the previous one.
return FALSE;
}
else
// First instance. Proceed as normal.
return TRUE;
}
CMyApp::InitInstance()
{
if (!FirstInstance())
return FALSE;
// ...
}
null@diku.dk, programmer.tools, 6/19/95
See also Win32 SDK Knowledge Base article Q124134 ("Allowing Only One Application Instance on Win32s") and Jeffrey Richter's Advanced Windows NT, chapter 7, "Prohibiting Multiple Instances of an Application from Running: The MultInst Sample Application" (available on the MSDN Library CD).
null@diku.dk, email, 8/8/95
Update—these were posted to mfc-l:
I have each InitApplication() create a semaphore. If GetLastError() returns ERROR_ALREADY_EXISTS then I know that some other application is already running and has gotten that far, so I bail.
Yourapp::InitInstance()
{
hMutexOneInstance =
CreateMutex(NULL,TRUE,_T("PreventSecondInstance"));
if(GetLastError() == ERROR_ALREADY_EXISTS)
bFound = TRUE;
if(hMutexOneInstance)
ReleaseMutex(hMutexOneInstance);
return (bFound == TRUE) ? FALSE : TRUE;
}
mcontest@universal.com
There is a nice section in Jeffrey Richter's book Advanced Windows NT about this. Essentially, it uses shared data segments between processes.
In your main file, add:
#pragma data_seg(".SharedData")
LONG nUsageCount = -1;
#pragma data_seg()
In your Application's InitInstance(), call:
InterlockedIncrement ( &nUsageCount );
This function returns the incremented value of the variable. If it is nonzero, you know that you are not the first App.
In your Application's ExitInstance(), call:
InterlockedDecrement( &nUsageCount );
In your .DEF file, have the following lines (note that the segment name you give here should match the one in the application's main file):
SEGMENTS
.SharedData shared
abalakri@us.oracle.com
You'd better use one of the built-in synchronization methods. See the Win32 Knowledge Base article Q124134, "Allowing Only One Application Instance on Win32s," for a sample of using a memory-mapped file for synchronization. It doesn't include starting the previous instance, but if you detect that you're not the only one running, it should be pretty simple: If CreateFileMapping fails, try to find the previous instance from the window class name. If it's not found, sleep for a while and start over (with CreateFileMapping). In this way, either you will find the other instance when it gets around to creating its window or CreateFileMapping will eventually succeed. The advantage of using CreateFileMapping instead of CreateObject is that it also works on Win32s.
nuj@kruger.dk
Note There's a sample of this that was contributed by john@jing.com (John Xu) called onetime4.zip that is in the MFC FAQ archive.
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
how to implement or integrate them into an existing VC++6 Diaglogue based program so that I can use some of the ActiveX Controls?
THanks
JW
DJ
|
|
|
|
|
Really appreciate your help!
JW
DJ
|
|
|
|