|
Hi!
Is there any way to make windows execute an app on shutdown? (something like HKCU\Software\Microsoft\Windows\Current Version\Run but for shutdown)
..or do I need to have an app running in background trapping the WM_ENDSESSION message?
Cheers, Marc Click to see my *real* signature
|
|
|
|
|
This is dependent on OS version.
For NT5+ you can do this using gpedit.msc.
|
|
|
|
|
How do you dynamically set menu item text? I am looking at all the ContextMenu methods, but there is no text setting methods. Any ideas?
thanks
|
|
|
|
|
MFC example:
CMenu *pMenu = GetMenu()->GetSubMenu(0);
pMenu->ModifyMenu(2,MF_BYPOSITION | MF_STRING, NULL,"New menu item text");
|
|
|
|
|
You will need to use ModifyMenu().. look up your documentation on CMenu
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it" Nish on life [methinks]
"It's The Soapbox; topics are optional" Shog 9
|
|
|
|
|
i am using the odbcrecordset class from the threat:
www.codeproject.com/database/odbcrecordset.asp
but i don't know how i can delete a recordset in my database?
someone has an idea???
thanx for help!!!
tom.
|
|
|
|
|
What do you mean by recordset? Do you mean you want to delete all of the data that is contained in your recordset? Or do you want to delete an entire table or view?
CRecordset (which ODBCRecordset is based on) has a Delete() function, which will delete the currently selected record. You could just loop through each record and delete it from the database.
If you want to drop an entire table or view, you should use the CDatabase class. Look at the ExecuteSQL() function.
|
|
|
|
|
int horzres = GetDeviceCaps(GetDC(GetDesktopWindow()), HORZRES);
int vertres = GetDeviceCaps(GetDC(GetDesktopWindow()), VERTRES);
COLORREF *pCol = new COLORREF[horzres][vertres];
VC++ says "non-constant expression as array bound". Why can i use a non-constant expression to create a one-dimensional array but i can't use a non-constant expression to create a two-dimensional array?
Thanks in advance.
|
|
|
|
|
ain't C++ great?
you'll have to do it something like this:
COLORREF ** pCol = new COLORREF *[horzres];
for (int i=0;i<horzres;i++)
pCol[i] = new COLORREF[vertres];
-c
Garbage collection, making life better - for weenies!
|
|
|
|
|
The reason is that vertres must be a compile-time constant. Eg. the following would work:
int horzres = GetDeviceCaps(GetDC(GetDesktopWindow()), HORZRES);
const int vertres = 600;
COLORREF (*pCol)[vertres] = new COLORREF[horzres][vertres]; But of course this is not what you want. Solutions:- Follow Chris' advice and construct an array of arrays. This complicates the destruction code, though.
- Use a one-dimensional array and index it like follows:
COLORREF *pCol = new COLORREF[horzres*vertres];
pCol[h*vertres+v]; - Use a
std::vector<std::vector<COLORREF> > .The construction code is as complicated as in 1, but at least you get automatic cleanup.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
wait a min
|
|
|
|
|
Does somebody know whatfor is LPDWORD lpThreadId in Win32 CreateThread() ?
MSDN says: lpThreadId, Pointer to a variable that receives the thread identifier.
I wonder, I get back a handle from CreateThread() which I use for closing/suspending etc, why do I need an additional identifier?
|
|
|
|
|
If you you're not going to need it, just set the parameter to null. I don't know much about it, but maby in some functions you need a "thread identifier" instead of a thread id.
|
|
|
|
|
thx! you brought more light into the dark.
I will do - or using _beginthreadex() instead.
|
|
|
|
|
consider file handles..
a file called "test.txt" is opened numerous times which results in different handles allowing access
it's the same with threads. they use dwords instead of strings as identifiers though
use OpenThread(des_access, inherit, threadid) to get the handle of any thread
so bottom line: a handle handles access but is not an id
|
|
|
|
|
Do not pass NULL as lpThreadId , this will cause CreateThread to fail in some Windows OSs. Instead, provide some variable to receive the ID and forget about it you like:
DWORD dwThreadId;
CreateThread(...,&dwThreadId); As for the meaning of this ID, you need it to set/get certain properties of a given thread. I don't know for sure the reason of this duplicity handle/ID (could be IDs are system-wide whereas handles are local to your program.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
could be IDs are system-wide whereas handles are local to your program.
Yes, at least in Win2k there is a process specific handle table that the kernel uses to modify kernel objects. In contrast the ID:s are used to identify the kernel objects themselves (making them system-wide).
I think Win9x uses another approach and is generally slacker on context switches, however.
/moliate
Two o'clock and walking through familiar London - Or what was familiar London before the cursor deleted certain certainties -
I watch a suit and tie man giving suck to the Psion Organizer lodged in his breast pocket
its serial interface like a cool mouth hunting his chest for sustenance, familiar feeling, and I'm watching my breath steam in the air.
Neil Gaiman - Cold Colours
|
|
|
|
|
The HANDLE is processpecific, while the TID is system-wide. If you don't intend to use it, just set it to NULL. As noted above this might not be a good idea for some OS's
/moliate
Two o'clock and walking through familiar London - Or what was familiar London before the cursor deleted certain certainties -
I watch a suit and tie man giving suck to the Psion Organizer lodged in his breast pocket
its serial interface like a cool mouth hunting his chest for sustenance, familiar feeling, and I'm watching my breath steam in the air.
Neil Gaiman - Cold Colours
|
|
|
|
|
I always seem to have the strangest problems with visual studio...
I have been working on a project that up until yesterday compiled and ran fine. Now, the debug version asserts on calls that load a resource, such as a menu or child dialog. In fact the program asserts when just trying to get the handle for the system icon of the main dialog box!
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
The assertion is always in AfxGetResourceHandle() which makes me believe that somehow Visual Studio has lost the "connection" between my user created dialogs, menus, etc. and the code that eventually loads them.
As I said before, nothing has changed in my project except that I have added a couple of new dialogs. I actually had this problem with one of the new dialogs yesterday too, but I was able to remove it from the project and put it back in and it worked fine -- it wasn't too much work since I had just added it. Obviously that isn't an option for the main dialog of my project...
Has anyone had a similar problem, and if so, how did you fix it?
TIA,
--Dean
|
|
|
|
|
Stock Visual response: have you tried doing a clean, full rebuild of everything?
Even if you win the rat race, you're still a rat.
|
|
|
|
|
I tried that but it didn't work. I went so far as to start comparing files such as .rc, .clw, and resource.[fd|h] with backup copies I made a while ago, and I couldn't see any difference other than due to the new resources I have added.
--Dean
|
|
|
|
|
This sounds very similar to a problem I had here when ever I added new resources, in the end I went through the app removing any unused resources that they may have been (you can end up with a few when development spans years / multiple developers... sigh)
I don't know what the details of the problem were, but it probably had something to do with running out of resource space
Dylan Kenneally
London, UK
|
|
|
|
|
I've had issues like that when i went through and manually edited the resource.h file.... to fix it, i just cleaned the project and did a rebuild all. i think devstudio just needs a kick to make it use the new constants.
hopefully this fix'll work for you!
|
|
|
|
|
Hey, Im having some trouble with capturing some events in an Outlook add-in. I was wondering if anyone had, or could give me an example of how to capture and overide an event such as the "open" event.
Right now I have this...
I derive my class from IDispSimpleEventImpl...
class ATL_NO_VTABLE CDaFun :
public IDispEventSimpleImpl<1,CDaFun,&__uuidof(Outlook::ItemEvents)>
typedef IDispEventSimpleImpl<1, CDaFun, &__uuidof(Outlook::ItemEvents)> ItmEvents;
Then setup a callback...
void __stdcall OnOpenItem(IDispatch* Ctrl, VARIANT_BOOL * CancelDefault);
and then the sinkmap...
SINK_ENTRY_EX(1,__uuidof(Outlook::ItemEvents),0xf003,OnOpenItem)
Now Advising im not sure about. Try to get a pointer to the interface i need. Im not sure if Inspectors is right...
CComQIPtr spApp(Application);
CComQIPtr spInsp;
spInsp = spApp->Inspectors;
ItmEvents::DispEventAdvise((IDispatch*)spInsp,&__uuido(Outlook::ItemEvents));
The advise fails, so im not how to set that up right. Please help
THanks
|
|
|
|
|
I simply can't remember it.
THanks in advance.
|
|
|
|