|
There's multiple ways to do this:
1. There's a wait for reboot option in MoveFileEx
MoveFileEx(src, dst, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
2. Download the update exe and run it. The update exe can post a message to the current application telling it to quit. Once it has exited then you can replace it with the update.
Todd Smith
|
|
|
|
|
Am I in much danger doing this? I wanted to see the TRACE
results w/o attaching a debugger, so I did this:
#ifdef _DEBUG
{
typedef BOOL (WINAPI* ISDEBUGGERPRESENT)();
ISDEBUGGERPRESENT pIsDebuggerPresent=(ISDEBUGGERPRESENT)GetProcAddress(GetModuleHandle("KERNEL32.DLL"),"IsDebuggerPresent");
if (pIsDebuggerPresent && !pIsDebuggerPresent())
{
ASSERT(!afxDump.m_pFile);
CString DumpFilename;
DumpFilename.ReleaseBuffer(::GetModuleFileName(0,DumpFilename.GetBuffer(MAX_PATH),MAX_PATH)?-1:0);
DumpFilename+=".TRACE-DUMP.TXT";
afxDump.m_pFile=new CFile(DumpFilename,CFile::modeWrite|CFile::modeCreate|CFile::shareDenyWrite);
}
}
#endif
I feel uneasy about it. Besides the problem of a debugger attaching to
the process later on, it may step on other dependencies of which I am
unaware. Is there a simple tool instead that will serve to receive and
display the TRACE messages?
|
|
|
|
|
|
Hello everyone.
I'm new to C++ and I can't get this to work.
Please let me know if I'm doing something wrong besides my problem
I can not update two fields in FoxPro database
it gives me an error "Can't update. Database or object is read-only"
This is how it goes:
CDaoDatabase* pDatabase = new CDaoDatabase;
pDatabase->Open("C:\\Work\\UpdateDBF\\INPUT", //path only!
TRUE, //exclusive?
FALSE, //read only?
"FoxPro 3.0;"); //connect string
CDaoRecordset rsCUST(pDatabase);
rsCUST.Open(dbOpenDynaset, "SELECT Custnum, noemail, norent FROM [CUST.dbf]");
rsCUST.MoveFirst(); //move to the beginning so we start from the begin
rsCUST.FindFirst( "Custnum = " + strCustNum );// strCustNum is a number i pull from a text file
if (rsCUST.IsEOF != 0){//if found the record
oleTemp.ChangeType( VT_BOOL );
oleTemp.boolVal = true;
try {
// this is where it fails
// the error i get is "Can't update. Database or object is read-only"
rsCUST.SetFieldValue("noemail", oleTemp);
rsCUST.SetFieldValue("norent", oleTemp);
}
catch(CDaoException* e){
TCHAR szCause[255];
CString strFormatted = _T("The data file could not be updated because of this error: \n");
e->GetErrorMessage(szCause, 255);
strFormatted += szCause;
AfxMessageBox(strFormatted, MB_OK | MB_ICONEXCLAMATION);
}
catch (...) {
TRACE ( "*** Unhandled Exception ***" );
}
} //if (rsCUST.IsEOF != 0){
If any one know please let me know
Thank you in advance.
ilya
iluha
|
|
|
|
|
I'm looking for an example of how to change images in a CListView. The items in my list can be edited, once edited I want to change the image so the user has a visual clue that the item has been modified. When the document is saved, the orignal image will be restored.
An example of this capability is Microsofts Visual Source Safe (VSS). When you check out a file, its image (file icon) gets a red check-mark and red border. When the file is checked in, the check-mark and border are removed.
I've experimented with I_IMAGECALLBACK, but it seems the callback only happens once when the item is inserted in the list control.
I've read a little about image overlays in MSDN, but I can't find enough information to make an attempt at using them. I'm not even sure if it's the appropriate solution.
Any help is much appreciated.
Marc
|
|
|
|
|
Use LVITEM structure with SetItem member function.
It's very easy!
A. Riazi
|
|
|
|
|
Hi everybody!
I have an exe projekt, and i want to load a child dialog from an dll.
The child dialog should be displayed at the parent dialog in the exe.
The parent dialog knows the rect where the child should be.
PLEASE!!!!
could anyone tell me how it works???
EMail: dawo.office@gmx.net
Thanks and best wishes!!
|
|
|
|
|
Create a regular dll. In dll resource, create your child dialog and specify it's ID. Run class wizard to make a class for your dialog.
Now export your dialog class.
In your exe, import your dialog definition. Use Create member function of your dialog to place it on parent dialog (do not use DoModal member function).
A. Riazi
|
|
|
|
|
Yes, create a Dll, and add in a dialog window and all the necessary stuff as you would for a normal exe. the catch is to add the exported methods (or functions or whatever you call them) to the out side user. here's an example of myddl.h with the exported create call:
//Flags for individual window features
#define SCROLL_VL 0x0001
#define SCROLL_VR 0x0002
#define SCROLL_HT 0x0004
#define SCROLL_HB 0x0008
#define TIC_VL 0x0010
#define TIC_VR 0x0020
#define TIC_HT 0x0040
#define TIC_HB 0x0080
#define STATUS_BAR 0x0100
#define ZOOM_BOX 0x0200
#define ORIGIN 0x0400
#define GRID_LINES 0x0800
//Conglomeration of some standard options
#define STANDARD_SCROLL 0x035A|ORIGIN
#define STANDARD_SCROLL2 SCROLL_VR|SCROLL_HB|TIC_VL|TIC_HB|STATUS_BAR|ZOOM_BOX|ORIGIN
#define STANDARD_VERTSCOPE SCROLL_VR|TIC_VL|TIC_HB|STATUS_BAR|ZOOM_BOX|ORIGIN
#define STANDARD_HORZSCOPE SCROLL_HB|TIC_VL|TIC_HB|STATUS_BAR|ZOOM_BOX|ORIGIN
#define STANDARD_SCROLL3 SCROLL_HB|TIC_VL|TIC_HB|STATUS_BAR|ZOOM_BOX|ORIGIN
//Flags used for cursor styles
#define DASHED_CROSS 0x0001
#define FULL_CROSS 0x0002
#ifdef __cplusplus
#define EXPORT extern "C" __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif
EXPORT BOOL CALLBACK CreateDisplay(HWND& hwnd,HINSTANCE hInstance,HWND parent_, int style, bool MDI_child);
Then in mydll.cpp I have this:
//******************************************************//
//Dll Entry point, no initialization needed //
//******************************************************//
int WINAPI DllMain (HINSTANCE hInst, DWORD fdwReason, PVOID pvReserved)
{
return TRUE;
}
EXPORT BOOL CALLBACK CreateDisplay(HWND& hwnd, HINSTANCE hInstance, HWND parent_, int style, bool MDI_child)
{
Display<double,double> *temp =
new Display<double,double>(hInstance,parent_,style,MDI_child);
hwnd = temp->GetHwnd();
the_displays[hwnd] = temp;
temp = NULL;
return TRUE;
}
Now my application uses template classes and my Display template class actually creates the Dialog window and attaches the Winproc, basically everything you normally do to create a normal windows app.
I hope this helps!
Dan Willis
|
|
|
|
|
Okay, suppose I've got a simple AppWizard generated application. I'm relying on the WinApp message pump and I've called SetTimer(1, 1, NULL) .
Since there is just one timer which is not being killed, does the message pump keep reactivating that timer or does it activate the timer, then sleep, then activate the timer again?
|
|
|
|
|
A timer continues until you either call KillTimer() or the thread terminates - take its message queue with it. If you don't need the timer; however, it's best to destroy it to save CPU cycles.
Jeremy Falcon
Imputek
|
|
|
|
|
Hello all,
I have a problem with my app. i have a CListCtrl where i need to change between Multiple selected and single selected with a check box.
I have been looking through the articles but didnt find anything.
Can anyone help me please?
In advance thanks, Michael Olsen
|
|
|
|
|
I am assuming the CListCtrl is similar in this regard to the CListBox. If anyone knows of a good way to do this with CListCtrl, I want to know too.
But I do know you can't do it with a listbox. The Windows designers apparently never figured that someone might want to switch between single select and multiple select at run-time...
So your options are as follows:
Create *two* list controls, right on top of each other, one is a Multiselect, the other is a Single select. Show only the one you want at any given time. Whenever you change between Single and Multiple select, show the appropriate list, and synchronize the contents. The disadvantage is that functions that do something to the list control have to be smart enough to know which one to use... or you have to make a wrapper class around the list controls to handle it.
Create a custom control, or derive a new control from CListCtrl and do the rest of the functionality manually. Then post it on CP as an article.
You can pick your friends, and you can pick your nose, but you can't pick your friend's nose.
|
|
|
|
|
Try this, but I haven't tested it:
ModifyStyle(0, LVS_SINGLESEL);
ModifyStyle(LVS_SINGLESEL, 0);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Is this the way to get one handler to run but have different code executed depending on the menu item clicked? Is there some other technique?
In the OnMYMenu() handler, I did:
CString strA, strB, strC;
CString str1 = "A";
CString str2 = "B";
CString str3 = "C";
mmenu->GetMenuString(ID_PALETTEA, strA, MF_BYCOMMAND);
mmenu->GetMenuString(ID_PALETTEB, strB, MF_BYCOMMAND);
mmenu->GetMenuString(ID_PALETTEC, strC, MF_BYCOMMAND);
if(strA == str1)
{
dostuff();
}
if(strB == str2)
{
m_palette.bitCount = 0;
} etc
Thanks
Appreciate your help,
ns
|
|
|
|
|
Perhaps you should have a look at ON_COMMAND_RANGE for your message map. It's the "normal";) way to get the same function called for different menu items.
|
|
|
|
|
I'm on it.......it looks really cool! Now I'm trying to code it, but I do have a sample so I'm fairly certain I can do it. Many many thanks.....this was precisely what I needed.
BTW, whats your suggestion on getting dynamic menu items to run a function (no ID range is set since the number is not known at all .....) - cant use ON_RANGE for that....I tried doing win2Ks WM_MENUCOMMAND but no luck. Do you have any suggestions?
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
BTW, whats your suggestion on getting dynamic menu items to run a function (no ID range is set since the number is not known at all .....) - cant use ON_RANGE for that....I tried doing win2Ks WM_MENUCOMMAND but no luck. Do you have any suggestions?
I'm not sure whether it really works (because never needed it) but I think overwriting CWnd's OnCommand could work.
|
|
|
|
|
Question: Do you think the compiler etc can handle it if I set aside say 500 IDs ?
Can I do this: in resource.h
#define ID_START 5000
#define ID_END 5500
Then as I go through doing AppendMenu
for (int i = ID_START; i < ID_END; i++)
{
psubMenu->AppendMenu(MF_STRING, i, tempSub);
}
Then I could use the On_COMMAND_RANGE....
Appreciate your help,
ns
|
|
|
|
|
Uhm ... I must admit I never thought of such a solution. but as I see it, it could work, provided that there's no other ID defined between 5000 and 5500. Give it a try and you'll know whether it's practical or not.;)
|
|
|
|
|
I want to use 'iphlpapi.h' (I want to be able to use GetAdaptersInfo) in a MFC application, but I get this message:
Cannot open include file: 'iphlpapi.h'
What can I do?
Thanks
-- n
|
|
|
|
|
install the platform SDK (see msdn.microsoft.com/sdk[^])
Holy Sh*t! I'm speechless. (hey, that's a first) Marc Clifton, The Lounge
|
|
|
|
|
Thanks, I just realized after posting this question.
Sorry!
Thanks a lot.
-- n
|
|
|
|
|
Yes, I just installed the SDK.
But I get this error:
c:\program files\microsoft visual studio\vc98\include\iphlpapi.h(183) : error C2065: 'PMIB_ICMP_EX' : undeclared identifier
Any ideas.
Thanks
|
|
|
|
|
It's solved including the right directories in tools / options / directories.
Thanks
|
|
|
|