|
This is code I use in my applications to solve this:
BOOL MyAppClass::InitInstance(void)
{
if (IsAppAlreadyRunning() == TRUE)
{
return (FALSE);
}
...
return (TRUE);
}
boolean MyAppClass::IsAppAlreadyRunning(void)
{
if (OpenMutex(MUTEX_ALL_ACCESS, FALSE, UNIQUE_APPLICATION_MUTEX_STRING) != NULL)
{
AfxMessageBox(_TEXT("Error! Application is already running, cannot start another instance."), MB_ICONEXCLAMATION);
return (TRUE);
}
CreateMutex(NULL, FALSE, UNIQUE_APPLICATION_MUTEX_STRING);
return (FALSE);
}
: Dean 'Karnatos' Michaud
|
|
|
|
|
http://www.codeproject.com/cpp/avoidmultinstance.asp
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
Within you lies the power for good - Use it!
|
|
|
|
|
In Your Dialogs InitInstance()
Add The Code
CreateMutex(NULL,FALSE,"Single");//last is the name u like
if(GetLastError()==ERROR_ALREADY_EXISTS)
{
//Thre is an instance exists.
//return from here
}
Renjith-The CPian.
|
|
|
|
|
I have a treeview control that was created with the property TVS_CHECKBOXES. When I insert a HTREEITEM I want to be able to specify whether it is checked or not. I am insterting the item like this.
HTREEITEM parent = m_treeView.InsertItem("root",TVI_ROOT, TVI_LAST);
any help will be appreciated.
Thanks,
Bill
|
|
|
|
|
I was thinking that SetItemState would do it but I am not sure what state to set.
Bill
|
|
|
|
|
try this:
m_treeItem.SetCheck( parent, TRUE );
-Raffi
|
|
|
|
|
I believe the following will work:
If m_treeView is a View, you need to get the control
CTreeCtrl & theCtrl = m_treeView.GetTreeCtrl() (This is from memory, so the syntax and spelling may be off a bit, but it's very close.)
Then use:
theCtrl.SetCheck(hParent, TRUE);
HTH
Ron Brunton (I haven't registered yet)
rbrunton@accesswave.ca
|
|
|
|
|
How to manually select entry in the taskbar ?
|
|
|
|
|
This is quite easy:
use ITaskbarList::ActivateTab for this purpose.
Try this:
ITaskbarList *pDisp = NULL;
CoCreateInstance( CLSID_TaskbarList, NULL, CLSCTX_SERVER, IID_ITaskbarList, (LPVOID *) &pDisp );
...
pDisp->ActivateTab(hWnd);
pDisp->Release();
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
100x thx
NodeX
|
|
|
|
|
I would like to implement a way to prevent a Dialogbox in MFC from being loaded on startup when it fails a check of some sort.
Thanks
|
|
|
|
|
In OnInitDialog check it and if it failed use PostMessage(WM_CLOSE)
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I hate to write this for a second time but I am still having trouble.
Hello All, thanks for reading this and for any help you may provide. I am having a problem, I used the "Building Office 2K Addins" article as a guide and I am trying to automate MS Word but I keep getting a compiler error. The error is:
StdAfx.obj : fatal error LNK1179: invalid or corrupt file: duplicate comdat "_IID_CanvasShapes"
I cannot figure out why I keep getting this link error. I am not sure what is causing this. Does any have any idea that may work, it works in the article but not for me. I have included a lot of the code, if anyone needs to see more, just let me know. I am in desperate need and am clueless!!!!
-----------------------------------------------------------------------------------
Instead of importing Outlook, I am trying to import Word in the stdafx.h:
#import "C:\Program Files\Common Files\Microsoft Shared\Office10\mso.dll" rename_namespace("Office") named_guids
using namespace Office;
#import "C:\Program Files\Microsoft Office\Office10\MSWORD.olb" rename("ExitWindows", "WordExitWindows"), named_guids, raw_interfaces_only
using namespace Word;
-----------------------------------------------------------------------------------
My stdafx.cpp looks like this:
#include "stdafx.h"
#ifdef _ATL_STATIC_REGISTRY
#include <statreg.h>
#include <statreg.cpp>
#endif
#include <atlimpl.cpp>
Why would I be getting error. I cannot get around it! PLEASE HELP!!!!
|
|
|
|
|
i use ScrollView and DrawIconEx
when i select preview mode icon draw zoomed ok
but then i print icon doesnot print????
i insert this code:
if (pDC->IsPrinting())
{
pDC->SetMapMode(MM_ISOTROPIC);
pDC->SetViewportExt(pDC->GetDeviceCaps(HORZRES),pDC->GetDeviceCaps(VERTRES));
pDC->SetWindowExt(GetTotalSize());
}
how i can print zoomed icon
|
|
|
|
|
Your best chance is to draw the ICON into a DIB of the right size and then use StretchDIBBits(), which should be available on all printer drivers (BitBlt is only sporadically supported)
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Is there a way to tell when any window is moving, similar to WM_MOVING or WM_WINDOWPOSCHANGING but it works for all windows?
-Raffi Yet another example of my bad programming skills.
|
|
|
|
|
You'll have to install a hook on the external processes to intercept their messages.
Jeremy L. Falcon<nobr>
Homepage : Sonork = 100.16311
"But everybody darlin' sometimes bites the hand that feeds."
"Remember in this game we call life that no one said it's fair."
"Just because you're winnin' don't mean you're the lucky ones."
Song: Breakdown - Album: Use Your Illusion II - Artist: Guns N' Roses
|
|
|
|
|
I have an application where file processing is spread over 3 DLLs (long story...)
The first DLL writes the file and the subsequent DLL read the file.
Occasionally, and on only a few systems, the file cannot be opened by the second DLL. The error is either CFileException::accessDenied or CFileException::sharingViolation. (Both have appeared)
I made sure that the file gets flushed before it is closed (helped somewhat), but the error is still occurring.
Any suggestions?
Thanks
|
|
|
|
|
I wonder if it's some kind of timing issue. What happens if you wait a little while and then try opening the file again?
Even if you win the rat race, you're still a rat.
|
|
|
|
|
If it fails for one of the listed reasons, I Sleep for a second and then try again. It usually works then (I haven't seen it fail yet).
I'd rather fix the real problem though, if possible.
|
|
|
|
|
Are you sure the file is always being closed? If you're running the app without the support of a debugger, this may go unnoticed to you. To make sure, you can write some kind of log file with the openings ans closings to determine if this is what's causing your problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
The close function is being called. The OS just doesn't get everything straight before the next call. I've duplicated it on a few system with a regular program.
Open for Write
Close
Flush
Open for Read (fails here)
Close
I've tried it with and without the Flush with similar results (happens less frequently with Flush)
Thanks
|
|
|
|
|
Shouldn't be Flush called before Close ?.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Close supposedly does its own flush. I've had the call before and after the Close. It has worked better after the close.
|
|
|
|
|
Hi all,
I wish to put some images (bmp, jpg, gif) in my application. Is there a way of reducing the sometimes large image file sizes...?
For instance, I have an app that's about 30 kb big without images, but adding 2-3 of them radically changes the exe size... suddenly around 400-500 kb (of course this depends on the image size).
Any ideas?
/T
|
|
|
|