|
Mustach posted:A good quick reference for the Standard Library is Apache's documentation. I would suggest just using the documentation of your actual documentation of the standard library.
|
# ? Sep 11, 2008 15:31 |
|
|
# ? Apr 24, 2024 18:04 |
|
Vanadium posted:I would suggest just using the documentation of your actual implementation of the standard library.
|
# ? Sep 11, 2008 15:51 |
|
Mustach posted:(Although a lot of the time they'll say "Visual C++" and mean C++/CLI.) Where do they do this?
|
# ? Sep 11, 2008 18:35 |
|
Mustach posted:It has benefits, though. It loads fast (unlike MSDN), it covers more and is better-formatted than SGI's, and is easier to browse than GNU's.
|
# ? Sep 11, 2008 19:55 |
|
Ugg boots posted:Where do they do this?
|
# ? Sep 11, 2008 20:31 |
|
I'm trying to find all the handles of windows with a certain class type. FindWindow() only seems to return the first, how would I get the rest?
|
# ? Sep 11, 2008 21:45 |
|
FearIt posted:I'm trying to find all the handles of windows with a certain class type. FindWindow() only seems to return the first, how would I get the rest? Use EnumWindows, like Pooball said, and GetClassName in the EnumWindowsProc to determine if the window is the class you want.
|
# ? Sep 11, 2008 22:21 |
|
Let's say I have a very large (~1.5 million lines, ~10k files) VC++ solution, with about 10 projects, all with interdependencies. Let's also say that with a relatively small amount of effort, I could turn that into about 50 projects, probably much more intertwined. Currently the ~10 projects each generate a static lib which is linked into the executable. What would be involved in making each of these new ~50 projects (with the exception of one, and some external libs) generate DLLs in debug or optimized debug builds, and have them linked in at runtime? What kind of startup performance impact would be involved with turning one giant 45 meg executable into a tiny executable and 50 DLLs that get loaded at startup? The goal of this would be to reduce incremental link times, which are currently about 5 minutes. Hopefully, if only one of these DLLs got changed, the link time would be nearly nonexistent... right?
|
# ? Sep 11, 2008 22:31 |
|
csammis posted:Use EnumWindows, like Pooball said, and GetClassName in the EnumWindowsProc to determine if the window is the class you want. I've been googling enumwindows for a couple hours now and I'm not sure exactly how its to be used, anyone have a link of an example?
|
# ? Sep 11, 2008 22:33 |
|
Have you come across the MSDN page for EnumWindows? http://msdn.microsoft.com/en-us/library/ms633497(VS.85).aspx
|
# ? Sep 11, 2008 23:04 |
|
ehnus posted:Have you come across the MSDN page for EnumWindows? Yeah, I've seen that page, I guess something's just not clicking. I tried writing it into my code but I'm not even sure how to parse the handles that have the correct class type or even how to get them out of the callback function once I do so..
|
# ? Sep 11, 2008 23:08 |
|
This might be more confusing than helping, but there is a Spy++ clone called WinSpy with source code available. Look for WinSpyTree.c. It uses the handy function EnumChildWindows to get all windows, even children of top-level windows: EnumChildWindows(GetDesktopWindow(), AllWindowProc, (LPARAM)<some parameter>); http://www.catch22.net/software/winspy
|
# ? Sep 11, 2008 23:13 |
|
FearIt posted:Yeah, I've seen that page, I guess something's just not clicking. I tried writing it into my code but I'm not even sure how to parse the handles that have the correct class type or even how to get them out of the callback function once I do so.. It's been a long time since I've done any windows api stuff(not since college), but I think I used to do something like: code:
|
# ? Sep 11, 2008 23:47 |
|
more falafel please posted:What kind of startup performance impact would be involved with turning one giant 45 meg executable into a tiny executable and 50 DLLs that get loaded at startup? quote:Hopefully, if only one of these DLLs got changed, the link time would be nearly nonexistent... right?
|
# ? Sep 12, 2008 02:36 |
|
I've been having some trouble understanding EnumWindows() so Im about to just try to run a loop with GetWindow() and the GW_HWNDNEXT flag. As I'm looping through these HWNDS I plan on just comparing the classes until I find matches, but how do I find the class name if I know only the HWND?
|
# ? Sep 12, 2008 09:15 |
|
Uh, GetClassName? EnumWindows() isn't that hard and is really the way you should do this. As it says on msdn's EnumWindows page: quote:This function is more reliable than calling the GetWindow function in a loop. An application that calls GetWindow to perform this task risks being caught in an infinite loop or referencing a handle to a window that has been destroyed. To use EnumWindows all you have to do is call it with your loopback function as the first parameter and whatever you want else cast to a LPARAM as the second. In your loopback you cast your LPARAM back to whatever it was before, do what you want to do and as long as everything goes ok, return true. Your loopback gets called until there are no non-child windows left(as long as you always returned true, if you return false it drops back out to the calling function) and when that's the case, you're dropped back in your calling function with a return value of true. It's been a really long time since I've had to do this, but I'm pretty sure this is about how it has to go: code:
TheSleeper fucked around with this message at 13:43 on Sep 12, 2008 |
# ? Sep 12, 2008 13:25 |
|
FearIt posted:I've been having some trouble understanding EnumWindows() so Im about to just try to run a loop with GetWindow() and the GW_HWNDNEXT flag. I was bored, so here's an example: code:
|
# ? Sep 12, 2008 13:49 |
|
Wow TY both, goons to the rescue! fake edit: how would I incorportate these both into an existing class? or could it be as easily as copy and pasting it in or putting my className::callback ... ? FearIt fucked around with this message at 22:22 on Sep 12, 2008 |
# ? Sep 12, 2008 22:11 |
|
Uh, you do it the same way you integrate any other function into a class. Are you new to C++? If so it might help to do some more reading and sure yourself up on the basics. Not being solid on that stuff now can REALLY come back to bite you in the rear end later.
|
# ? Sep 12, 2008 22:46 |
|
TheSleeper posted:Uh, you do it the same way you integrate any other function into a class. Are you new to C++? If so it might help to do some more reading and sure yourself up on the basics. Not being solid on that stuff now can REALLY come back to bite you in the rear end later. Nah, I'm pretty versed in C++, I've just never dealt with CALLBACK functions before.
|
# ? Sep 12, 2008 23:34 |
|
error C3867: 'interfaceDesktop::EnumWindowsProc': function call missing argument list; use '&interfaceDesktop::EnumWindowsProc' to create a pointer to member I got the following error on the line EnumWindows(EnumWindowsProc, (LPARAM)windowClassToFind); I'm not sure what I should do
|
# ? Sep 12, 2008 23:45 |
|
You can't use a class member function as a callback. How would it know what "this" is? Use a static or free function.
|
# ? Sep 12, 2008 23:47 |
|
Ok I've taken the function out of the class but now I get an error C2664: 'GetClassNameW' : cannot convert parameter 2 from 'char [256]' to 'LPWSTR' on the line GetClassName(windowHandle, windowClassName, sizeof(windowClassName)); I've tried casting windowClassName as an (LPWSTR) but then the code compiles but does nothing. Edit: I figured it out, VS was preset to unicode, I changed to to multibyte and it worked fine, thanks for your help! FearIt fucked around with this message at 00:22 on Sep 13, 2008 |
# ? Sep 13, 2008 00:13 |
|
haywire posted:Where should I start? Are there any good goon recommended free tutorial sites I can busy myself with before I sink money into a good book? Right now I'm going through the Accelerated C++ book as all others really piss me off and don't move fast enough for me. It does get a little "THIS HOW YOU PRINT "HELLO WORLD" GEE WIZ" in the beginning but it picks up the pace a little faster and teaches you actually useful things first, then goes deeper into them in the later chapters. I'm going to skim through Thinking in C++ vol 1 since I think Bruce knows what he's talking about, and try to look into vol 2. I'm also taking a course called "Advanced Programming" that goes through everything in the beginning programming courses up to Data Structures, but this time in C. I like my prof. since he's making me get off my lazy rear end and learn some *nix.
|
# ? Sep 13, 2008 00:42 |
|
FearIt posted:I've tried casting windowClassName as an (LPWSTR) but then the code compiles but does nothing. This is the worst way to solve compile errors in C/C++. Your solution isn't that great either. Why not pass in L"MyString" or _T("MyString")? (I forgot the right one to use.) floWenoL fucked around with this message at 04:35 on Sep 13, 2008 |
# ? Sep 13, 2008 04:26 |
|
floWenoL posted:This is the worst way to solve compile errors in C/C++. The documentation for GetClassName() says it takes an LPTSTR, which you construct with _T("MyString") (don't forget to include tchar.h!)
|
# ? Sep 13, 2008 04:56 |
|
Not strictly a C++ question, but pretty close. I have a memory issue which I don't understand. My executable loads a DLL, which contains various managers for my game. When I have a class which is exported by the DLL, and I create an instance of it in the executable, hand it back to the DLL and then delete that instance in the DLL, I get a memory fault. Likewise, if I have a class defined in my exe which I pass over to the DLL (eg an abstract factory), and then delete that class in the DLL, I get a fault. On the other hand, if a class is defined and instantiated by the exe, and then given to the DLL which deletes it, everything is OK. I'm using the same multi-threaded DLL CRT for everything, so I don't quite know what's up. edit: I realise handling memory like this is bad practice, and I intend to refactor, I'm just curious because I haven't been able to find a reason why this doesn't work. newsomnuke fucked around with this message at 13:37 on Sep 13, 2008 |
# ? Sep 13, 2008 12:33 |
|
ultra-inquisitor posted:Not strictly a C++ question, but pretty close. I have a memory issue which I don't understand. My executable loads a DLL, which contains various managers for my game. Never delete memory allocated in an exe from a DLL or the other way around. Call the corresponding delete for each object -- people often accomplish proper deletion by adding a virtual "release" member function that simply calls delete this. Call that function instead of calling delete. That Turkey Story fucked around with this message at 23:03 on Sep 13, 2008 |
# ? Sep 13, 2008 22:16 |
|
Anyone have a decent resource for serial communication with C++? Googling yields lots of links with dubious quality.
|
# ? Sep 13, 2008 22:43 |
|
That Turkey Story posted:Never delete memory allocated in an exe from a DLL or the other way around. Call the corresponding delete for each object -- people often accomplish proper deletion by adding a "release" member function that simply calls delete this. Call that function instead of calling delete. code:
code:
code:
I was also under the impression that if you used the DLL CRT, then exe and DLL would use the same heap manager, so this wouldn't happen in the first place, but I guess I'm missing something.
|
# ? Sep 13, 2008 23:14 |
|
n/m
Chuu fucked around with this message at 23:44 on Sep 13, 2008 |
# ? Sep 13, 2008 23:35 |
|
That Turkey Story posted:Never delete memory allocated in an exe from a DLL or the other way around. Call the corresponding delete for each object -- people often accomplish proper deletion by adding a virtual "release" member function that simply calls delete this. Call that function instead of calling delete. Can you elaborate on what the deal is with that? I have no idea how Windows works, but that sounds somewhat silly.
|
# ? Sep 14, 2008 02:22 |
|
On Linux, using Ncurses' getch() blocks by default, waiting for input, on Windows using Cygwin it doesn't for some reason. Anyone know why? I tried specifying nocbreak() for "cooked mode" and it didn't seem to help. code:
|
# ? Sep 14, 2008 10:32 |
|
I need some help on an assignment (this is like the very first thing I've done in C so I'm sure the code is really gay and stupid) The point is to scan in an input.txt file, which is just a bunch of numbers separated by lines, with the first number being how many numbers there are. Then we're supposed to bubble sort it and print out the numbers. The problem is that instead of numbers, it prints random characters?? I have no idea code:
code:
code:
|
# ? Sep 15, 2008 01:28 |
|
That's because you're telling it to print a character. "%c" is "print a character". You want "%d"
|
# ? Sep 15, 2008 01:30 |
|
Avenging Dentist posted:That's because you're telling it to print a character. "%c" is "print a character". You want "%d" Oh, duh, I changed it to d for the scan but not for the second line. Thanks.
|
# ? Sep 15, 2008 02:08 |
|
Thug Bonnet posted:On Linux, using Ncurses' getch() blocks by default, waiting for input, on Windows using Cygwin it doesn't for some reason. Anyone know why? getch man page: In no-delay mode, if no input is waiting, the value ERR is returned. In delay mode, the program waits until the system passes text through to the program. nodelay man page: The nodelay option causes getch to be a non-blocking call. If no input is ready, getch returns ERR. If disabled (bf is FALSE), getch waits until a key is pressed. It doesn't say what the default option is. I guess it might be inherited, which would explain the difference in behavior.
|
# ? Sep 15, 2008 05:12 |
|
Stupid question time. I'm sure that this is a really trivial problem, but unfortunately I'm retarded when it comes to strings; I can't internalise how they work at all, or even really understand them. I have a string StringX in the form of an LPSTR (that is, char*). I don't have the option of trying to use another string data type because LPSTR is the form in which Windows returns the string from the function used to obtain it. I want to test whether that string is the empty string, "". StringX is a global variable of type LPSTR. I use the function GetWindowText(TextBoxHwnd,StringX,25) to assign the text in the edit control TextBoxHwnd to StringX. (Entry of text into TextBoxHwnd is limited to 20 characters.) My thinking is that since LPSTR is char*, that means that *StringX is a variable of type char. So if I write code:
code:
|
# ? Sep 15, 2008 07:47 |
|
Are you sure StringX is non-null?
|
# ? Sep 15, 2008 07:50 |
|
|
# ? Apr 24, 2024 18:04 |
|
StringX is uninitialized... you don't actually want an LPSTR (unless you allocate memory for it), you want an array of characters: char StringX[25].
|
# ? Sep 15, 2008 08:01 |