|
Woah - no need to come out swinging !!!
Alvaro Mendez wrote:
I answered the guy's question and gave him a solution. It's not your solution, but then again, I didn't say it was better than yours. It's just an alternative. Does it work? Yes! Then why ask why?
Effeciency ? Ultimately, if you have a CString, why not use the functions CString provides to do such things ? If you're not going to use them, there's no reason not to prefer std::string.
Alvaro Mendez wrote:
Now as for the CStringArray class... woah, a class that encapsulates an array of CString objects. Gee, that sounds like the most *useless* class possible for storing CString objects inside an array! I really really ought to consider alternatives, like the STL classes. Those are really intuitive and well documented, right? That's what I thought.
Yes, they ARE intuitive, and despite M$ giving you no real help with them, there is great help available online at the STL site, and also a number of very good books.
So you've got your CStringArray. Now sort it. Sort it again, randomly. Now provide me with all available permutations. Ooops. Looks like the STL wins out again.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
OK OK, no need to fuss over which solution is better here.
I just think CString and CStringArray can satisfy our needs over 90% of the time. They're part of MFC, they're used and supported by other MFC classes, and they're well documented by Microsoft. So I say use them, especially if you're just getting into MFC.
STL is a fine library, except for 2 things: 1) it's not well documented by Microsoft, and 2) it's not all that intuitive, especially when it comes to function names. Sure, once you start getting the hang of it and know where to find its documentation, it's fine. But you could just as well go with the MFC counterparts and do equally fine, in less time.
As far as sorting goes, nope, you can't sort a CStringArray directly. I actually wrote some pretty nifty functions that do it using the qsort function, but that's beside the point. STL is great for that and more, but then again... how many of us need to sort arrays of strings inside our programs? In my 10 years of Windows development, I think I've only done it twice - hence my nifty functions.
Perhaps the best reason to use STL is multi-platform support. That's where STL reigns supreme. But for Windows development, I still favor the MFC classes.
Regards,
Alvaro
|
|
|
|
|
Hey. I'm making a program in Windows API in C++ (not MFC). I'm trying to add picture files onto buttons, or just on the form and when you click them, it processes an event.
Any help on how to load a .gif or any picture file onto a form or button? Thanks =)
Dave
|
|
|
|
|
You can use GDI+ to load a gif. You can use ::LoadImage to load a bmp from disk or resources. Then make the button owner drawn, and draw the bitmap onto it using the WM_DRAWITEM message. You can use an STL map to map the windows HWND to a bitmap to avoid global data, or better yet, wrap your buttons in a class and map the HWND to the pointer to the class instance.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Is there any way to mimic the behavior of PrintInsideRect() when printing from a CScrollView?
Printing... what a pain.
|
|
|
|
|
Yes, do the printing yourself
Catch OnPrint in your derive CScrollView.
- God bless the World
|
|
|
|
|
Any guidance on how to tell programatically whether Visual C++ is running? The simplest solution would appear to be if there is a known mutex that I could refer to, but I have had no luck finding any such information in MSDN or on the web.
Failing that, other suggestions also welcome. It's with a view to writing installer(s) using Martijn Laan's "My Inno Setup Extensions", so I can write an extension DLL in C++ if necessary.
Cheers,
Gavin Greig
|
|
|
|
|
You need to Use PSAPI Functions.
Start with ProcessEnum Function...
I wrote a class that Do that you need...
If you want for a I can share the class with you....
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Also you can See what Applications Are running enumming the HWND...
Also I Wrote a Class that Do that....
The Principal difference is that for PSAPI functions you need the psapi.dll that is only in NT and W2K, Don't work under win 95/98. I don't Know what happens with XP..
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
There are two simple ways:
1. Enumerating processes. You can use the following classes to enumarate processes on both NT/2000 and Win9x. http://www.codeproject.com/threads/enumprocess.asp
2. You can use FindWindow API to find Visual C++ window. You can also give the class name as a parameter to be sure that the window found is Visual C++ Window.
Hope this helps.
Kind regards
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
|
|
|
|
|
Thanks guys, I'll look into these.
Cheers,
Gavin Greig
|
|
|
|
|
Does anyone know where i can find a good example that shows how to send a file over the internet from one app to the other??
Kuniva
--------------------------------------------
God gave man a penis and a brain but not enough blood to make both of 'em work at the same time.
|
|
|
|
|
Suppose I have a process's handle, how can I figure it's CPU usage?
(Same about it's memory usage)
10x, be blessed.
--BlackSmith--
"With the help of all mighty", 2001, Me.
|
|
|
|
|
For NT 4.0/2000/XP sistems, seems like GetProcessTimes was written thinking of you
As for memory usage, the function to go is GetProcessMemoryInfo (implemented as part of the PSAPI performance Monitoring SDK).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sorry for the ignorence, but suppose I called GetProcessTimes() and converted the FILETIME arg' to SYSTEMTIME (using FileTimeToSystemTime(),
how do I compute (and which parameter is the significant) the CPU usage of a process per second?
truthfully yours, Me.
--BlackSmith--
"With the help of all mighty", 2001, Me.
|
|
|
|
|
SYSTEMTIME is not a good choice to calculate relative times.
To compute CPU usage per second, just call GetProcessTimes every second and compute the difference of the paramaters lpKernelTime (time spent inside system routines) and lpUserTime (time spent inside user code). To subtract two FILETIME s, copy them to ULARGE_INTEGER s and subtract these (more info about FILETIME arithmetic on the online documentation about FILETIME ).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
There are two simple ways:
1. Enumerating processes. You can use the following classes to enumarate processes on both NT/2000 and Win9x. http://www.codeproject.com/threads/enumprocess.asp
2. You can use FindWindow API to find Visual C++ window. You can also give the class name as a parameter to be sure that the window found is Visual C++ Window.
Hope this helps.
Kind regards
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
|
|
|
|
|
|
I am working on an MFC MDI application. I'd like to have the document title (in the app's title bar) display an asterisk at the end when the document has been changed. When the document is saved, the asterisk disappears. MS Visual Studio's text editor has this capability.
Any suggestions on how to add this capability?
Marc
|
|
|
|
|
With AfxGetMainWnd you can get The main window Handle then you can use GetWindowText for read the Title and add a Asterisk when the docuement is changed using SetWindowText for write the new title. But Warning you can fill the Title with several asterisks, you need a control like a variable for this...
Regards...
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
CDocument provides some methods to maintain the "changed and unsaved" state, namely IsModified and SetModifiedFlag . I guess the best solution is to override SetModifiedFlag (assuming your app is using this method consistently) and change there the document's title accordingly using SetTitle .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Uh, i've tried a few dozen times to write a function that sees if a certain item of a list is also in another list but it just wouldn't work. And there's also a second difficulty, but i'll explain by giving the information needed:
First of all, its not really a list, but its several strings i can get after eachother. I have to parse a line of text wich uses '#' as a seperator like this:
cookoo#woowoo#blabla#weewee
this is the string(mystring) and i parse it with AfxExtractSubString(...) like this:
int index=0;
while(AfxExtractSubString(Item, LPCTSTR(mystring), index++, '#')
{
if(Item!="")
// Item is a good string so...
}
}
This is the same way for the two lists/strings only that the second string/list contains less or as much substrings as the first string/list and the strings the second string/list contains are always in the first one. BUT! it is possible that certain string(s) in the second one have '[' in front of it and ']' behind like this:
weewee#[woowoo]#gaga#blabla
i need to see this and make a difference between strings that have [] and strings that dont.
So the main goal is to see if any items from the first string/list are in the second one and if they have [] or not.
Can anyone help me with this as my brain seems to lack stamina for this.
Kuniva
--------------------------------------------
God gave man a penis and a brain but not enough blood to make both of 'em work at the same time.
|
|
|
|
|
Try something like this:
int index=0;
int index2;
CString mystring;
CString csSecondString;
while(AfxExtractSubString(Item, LPCTSTR(mystring), index++, '#')
{
if(Item!="")
{
int n = csSecondString.Find(Item);
if (n > -1)
{
if (n>0)
{
if (csSecondString[n-1] == "[" &&
csSecondString[n+Item.GetLength()] == "]")
{
}
}
}
}
}
Hope this helps,
Bill
|
|
|
|
|
I was browsing the internet when i came across a free utility that enables you to make your pc accessible using a static name, such as www.123-321.com, and wondered if anyone knew how to make that.
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|
|
The Eclypse wrote:
I was browsing the internet when i came across a free utility that enables you to make your pc accessible using a static name, such as www.123-321.com
Using any user-selectable domain name? Now that would be impressive...
Peace!
-=- James.
|
|
|
|