|
This is a common task ( actually, it's a common homework task, is this homework ? )
Think about what you want to do. Think about how your brain processes it. Then think about how to reproduce that in code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Nah, that'll never work. You're asking the OP to do something many recent posters here can't. You asked for it three times
I have some VBA code for generating page footers in Excel which includes a page number in Roman numerals, if that's any help ...
Steve S
Developer for hire
|
|
|
|
|
Do you need to convert string to number
|
|
|
|
|
Are you wanting
123 = 'one hundred twenty three'
or
123 = '123'
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Ladies and gents,
We have a small suite of programs that automate sending recorded voice audio files to a user provided e-mail address. In the next version, we would like to import the user's Outlook or Outlook address book details rather than having duplicate e-mail address books on the system. Can someone point me to an easy way to do this, preferably in C++?
Regards,
Steve
|
|
|
|
|
Hi Steverty,
This was a code that we created for some of our application. Use it if it seems useful to you...
_ApplicationPtr pApp;
_ItemsPtr pItems;
MAPIFolderPtr pFolder;
_ContactItemPtr pContact;
HRESULT hr;
try
{
hr=pApp.CreateInstance(__uuidof(Application));
if (FAILED(hr))
{
MessageBox("Unable to instantiate Outlook.",
"Outlook Error",MB_OK);
return 0;
}
if (true)
{
pFolder=pApp->GetNamespace(_bstr_t("MAPI"))->
GetDefaultFolder(olFolderContacts);
if (pFolder==NULL)
{
MessageBox("Could not find default contacts folder.",
"Outlook Error");
return 0;
}
}
else
{
pFolder=pApp->GetNamespace(_bstr_t("MAPI"))->PickFolder();
if (pFolder==NULL)
return 0;
if (pFolder->GetDefaultItemType()!=olContactItem)
{
MessageBox("Select folder is not a Contact folder.",
"Outlook Contacts");
return 0;
}
}
pItems=pFolder->GetItems();
if (pItems==NULL)
{
MessageBox("Unable to get Contact Items.","Outlook Error");
return 0;
}
pContact=pItems->GetFirst();
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I have an mfc app that is behaving badly - exhibiting random lockups. It might be the OS, but I don't think so The hang appears to happen when I am leaving a dialog.
I have two styles of leaving a dialog, and based on what I have read in the MS doc, both should be okay. Style 1:
class::OnClickExitBtn()
{
// release all dialog resources.
EndDialog(IDC_EXIT_BTN);
}
Now, in the MS doc, it states that EndDialog sets a flag in the message pump such
that the dialog will exit. Of note is that it will not process any further messages.
Style #2 is:
class::OnClickExitBtn()
{
// All allocated resources in this class released in destructor.
EndDialog(IDC_EXIT_BTN);
}
Style 2 simply moves everything to the destructor. I thought this had cleaned up the hangs, but one just happened again.
So, what is the correct exit procedure from a dialog with allocated resources, timers, etc? Any practical experience to shed some light on this? A past project was very suspicious of SetTimer and avoided it like the plague - using a thread to generate an application message....
Thanks for your thoughts...
chg
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
I've used SetTimer extensively, and not had it cause the problem you describe. The reason most people have problems with it is that they expect it to be accurate. Windows' handling of WM_TIMER messages is such that they don't occur at the interval you expect. BTW, you don't need to issue a KillTimer() when you exit your dialog.
Rather than deallocating things and releasing resources in the destructor for my CDialog objects, I usually override PostNcDestroy() for that sort of thing. This seems to match up better with initialization performed in an OnInitDialog() override. It also works better when you re-use a given CDialog -derived object.
Software Zen: delete this;
|
|
|
|
|
I agree that the SetTimer can be wildly inaccurate, but for me, I just need the periodic event. I also concur with what you say about timer cleanup. I'll do some more reading on the PostNcDestroy method... maybe something is there.
Thanks
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
Gary - one other question - reading about PostNcDestroy, MS says, "Derived classes can use this function for custom cleanup such as the deletion of the this pointer."
Now, I only use the dialog via .DoModal(). Based on what I've read, I would only need to worry about this if I had done a Create operation...
Sorry, grasping for any kind of memory or resource leak....
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
The only time you're going to use delete this; is if you're not deleting the MFC object somewhere else. I've only used this in rare cases, where I had a modeless dialog that I wanted to destroy its own MFC object when the dialog closed. If you're using DoModal() then that's not the case.
BTW: Don't mind my sig .
Software Zen: delete this;
|
|
|
|
|
Ah yes, I recall reading about when you delete and when you don't - I use domodal almost exclusively, so I'm okay there.
Hadn't even noticed the sig, but then, I like it.
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
Any resources that are associated with the HWND (such as timers) need to be cleaned up while the window still exists. THerefore, the destructor is the wrong place to clean up times since the window is already gone by the time the C++ object is destroyed.
|
|
|
|
|
hi
i wanna use *.exe file such az static library.
a static library included in my exe file, so i wanna my exe file involve another exe file(with out any source code from second exe file) and can run second exe file in my exe file.
it can be used to check authentication of user to use an unknown exe file.
can any one help me?
|
|
|
|
|
You can't "use" another exe as a static library. If the other exe exposes automation interfaces, you can make calls in it (or if it is a COM server/service). Otherwise, you can call it using a system call. The first case is not statically bound, and the system call is not bound at all.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I have an app now that takes input from a COM port and would like to add the ability to take input from a USB device such as a keyboard, barcode scanner, or other device.
I connected a barcode scanner to my machine and it looks like an HID to the machine - specifically a USB keyboard. I went into the HKLM\System\CurrentControlSet\Control\DeviceClasses registry entry and removed all the entries from there. I then plugged this scanner in again and noted the SymbolicLink values for the registry entries created.
I have another application that talks directly to USB printers, and to talk to them, I do a CreateFile with the SymbolicLink values from under the DeviceClasses registry entry. This works just fine, and I get back a valid handle.
When I do the same thing for this USB barcode scanner's entries, I get INVALID_HANDLE_VALUE back from CreateFile for each one.
I need to be able to differentiate input from the USB barcode scanner and a regular keyboard, since I can take input from the keyboard also.
Thanks for your help!
David
|
|
|
|
|
I have about the same problem.
Did you find a solution yet?
Allso, I'm searching how you can capture the barcode-imput while you don't allow it to be send to the active application (normally, when you have e.g. word open, the barcode-number is send as trext to the screen). I want the barcode number to be available without it being send to Word...
How can I do that?
Thanks.
-- modified at 2:41 Sunday 28th January, 2007
|
|
|
|
|
Environment is Visual C++ 2003 Standard Edition.
According to MSDN concerning the Properties view in Visual Studio Link[^]
Overrides
Lists all virtual functions for the selected class
and allows you to add or delete overriding functions. However, I have a class that derives from a class that derives from CObject. The object that derives from CObject has mostly virtual functions. However, if I click on any class, I cannot see those virtual functions in my properties view/overrides section. I only see the overrides for CObject regardless of the class selected.
Is it incorrect to expect my derived class' virtual functions to appear in the overrides section?
|
|
|
|
|
Seems like, it shows overridables from MFC classes only. But not mentioned in its description.
|
|
|
|
|
That appears to be the way it's behaving.
I am holding out hope that I'm not doing something right but it's becoming apparent that it's designed to only show their stuff.
Anyway, Thanks for the reply
|
|
|
|
|
Some of our users do not have a desktop computer, so myApp installs itself on the PocketPC using Autorun.exe. Currently I have a CF1 (compact framework) install program. I am upgrading myApp to CF2 so I need to write a C++ app to install the CF2 CAB file, then call my CF1 based install app to finish the program installation.
I have created a VS 2005 Wind32 Smart Device Project console program for autorun.exe. The return value from CreateProcess is 0, the lastError value is 87. Any help would be appreciated.
void _tmain( VOID )
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
LPTSTR szCmdline=_tcsdup(TEXT("\"wceload \\2577\\NETCFv2.ppc.armv4.cab\""));
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
BOOL res=CreateProcess( NULL, // No module name (use command line)
szCmdline, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ); // Pointer to PROCESS_INFORMATION structure
int lastError;
// Start the child process.
if( !res)
{
lastError = GetLastError()
printf( "CreateProcess failed (%d).\n", GetLastError() );
return;
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}
-- modified at 13:04 Wednesday 13th September, 2006
|
|
|
|
|
Hallo, insted of my previes questien, can any one tell me a way to put image as background in a ListView in Bordlan c++??
Sorry for bad english!
Greatings
Sigmac
|
|
|
|
|
You can do that with LVM_SETBKIMAGE
|
|
|
|
|
Ok, thansk, but i have no eksperiens in coding beyond drag drop element, i have fount this code on the Net Perform() is it whit this?
And how?
Greatings
Sigmac
Sorry for bad english
|
|
|
|
|
I have solved the problem.
in event CustomDraw in ListView1
Graphics::TBitmap *pBitmap = new Graphics::TBitmap();
try{
pBitmap->LoadFromFile("ikke-navngivet.bmp");
Canvas->Draw(0,0,pBitmap);
pBitmap->TransparentMode = tmAuto;
Canvas->Draw(50,50,pBitmap);
}
catch (...){
ShowMessage("Could not load or display bitmap");
}
ListView1->Canvas->StretchDraw(ARect,pBitmap)
delete pBitmap;
Gratings
Sigmac
Sorry for bad english
|
|
|
|