|
JoeNotCharles posted:Have you tried Googling "CreateProcess example"? I'm trying to do this without .net if possible.
|
# ? Jun 24, 2008 04:24 |
|
|
# ? May 18, 2024 02:05 |
|
There are examples down at the bottom of the MSDN page: http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx
|
# ? Jun 24, 2008 04:34 |
|
FearIt posted:I'm having trouble understanding all the arguements is there anyway I could get an example of CreateProcess? It's pretty simple actually. code:
|
# ? Jun 24, 2008 05:21 |
|
slovach posted:It's pretty simple actually. Looks like at least some browsers (Safari at least) treat & p i ) ; as & p i ;, which should render as the pi symbol.
|
# ? Jun 24, 2008 08:13 |
|
Here's a dirt-simple process wrapper app I did a while ago. We used it to launch windowed apps from a batch file (as part of an automated asset building process) so that the batch file would wait until the app had closed down before carrying on.code:
|
# ? Jun 24, 2008 11:26 |
|
more falafel please posted:Looks like at least some browsers (Safari at least) treat & p i ) ; as & p i ;, which should render as the pi symbol. I see the PI symbol, and I'm on Firefox 2. Looks like & p i itself makes the PI symbol (it ignores the character following it, i.e. doesn't wait for a semi-colon.) &pi
|
# ? Jun 25, 2008 17:23 |
|
It is not browser specific, the forums do the substitution. You can tell by looking at the source.
|
# ? Jun 25, 2008 17:28 |
|
Vanadium posted:It is not browser specific, the forums do the substitution. You can tell by looking at the source. Except I see &pi in Opera in the posts above, not π
|
# ? Jun 25, 2008 17:51 |
|
Vanadium posted:It is not browser specific, the forums do the substitution. You can tell by looking at the source. What? The source shows me the & p i, not the symbol.
|
# ? Jun 25, 2008 20:13 |
|
Fun, I get a pi symbol if I use the View Selection Source button, but a &pi if I use the regular View Source one. Blaming a javascript substitution Vanadium fucked around with this message at 21:08 on Jun 25, 2008 |
# ? Jun 25, 2008 21:05 |
|
Anyone know which TR1 standard library has better performance? Usually I'd just use Boost's TR1 imp, but VS2008 has it available now as well. Function objects is the main thing I'm after.
|
# ? Jun 25, 2008 22:54 |
|
The differences are probably negligible, and since they're both implementing the same standard, you can switch later on if you find that a particular implementation is unreasonably slow.
|
# ? Jun 25, 2008 23:15 |
|
Vanadium posted:It is not browser specific, the forums do the substitution. You can tell by looking at the source.
|
# ? Jun 25, 2008 23:34 |
|
Mustach posted:If you view the source in Firefox, it shows you the source as modified by FF, not the original. Actually, this is only true if you view the source of a selection.
|
# ? Jun 26, 2008 01:19 |
|
I'm trying to const_cast a class * const to a class * and getting an access violation exception. I'm guessing there's some assembly optimizations with pointer consts that I dont know?
|
# ? Jun 26, 2008 13:28 |
|
tyrelhill posted:I'm trying to const_cast a class * const to a class * and getting an access violation exception. I'm guessing there's some assembly optimizations with pointer consts that I dont know?
|
# ? Jun 26, 2008 14:17 |
|
Ah, I guess I won't be doing that little hack then... Thanks!
|
# ? Jun 26, 2008 23:34 |
|
I'm learning how to program in C++, using the Windows API, and as a project to focus on I'm trying to program a computer implementation of an obscure board game. I'm currently learning how to use user-defined buttons, that is buttons with the BS_OWNERDRAW style. I managed to successfully get the application to create a button, paint it using a bitmap picture of the same size as the button, and handle the BN_CLICKED message to do something (change the value of a single variable, and redraw the parent window). Now I want to have two such buttons and have each one do something different, but I am having problems getting the handlers to do different things based on the button that sends the message. I think the problem is one of obtaining the correct HWND. Here is the code I used to create the buttons; it is in the WM_CREATE case in the WindowProcedure function. code:
code:
EDIT: Never mind! I sorted it out by myself. Needed to declare the HWNDs page2btn and page3btn in the global scope and merely assign them to windows in the WM_CREATE code. Hammerite fucked around with this message at 18:13 on Jun 27, 2008 |
# ? Jun 27, 2008 16:30 |
|
Hammerite posted:I'm learning how to program in C++, using the Windows API Good God, why?
|
# ? Jun 28, 2008 06:06 |
|
I decided it would be quite cool to be able to say I'd actually learned a programming language. When I was a kid we used to have a BBC Microcomputer with Basic on it, and I'd muck around writing little noddy programs on it that didn't do anything very interesting, but I never really learned to do anything advanced. I know how to use HTML and LaTeX (markup languages), but couldn't actually claim to know any programming languages. As for why that language, I knew that a lot of stuff is programmed in C++. And for the "Windows API" part... bear in mind that that is my attempt to describe what I'm doing. I don't have a perfect command of all the technical terms involved here, and I may have inadvertently said I'm doing something I'm not. I'm creating a program to run in Windows, that displays graphics on the screen and that the user interacts with by clicking buttons. That's what I mean by what I said. I guess what I meant was "Windows GUI". I did a few little exercises that involved console programs first, but then graduated to making Win32 programs.
|
# ? Jun 28, 2008 10:27 |
|
Hammerite posted:I decided it would be quite cool to be able to say I'd actually learned a programming language. Learning C++ is fine in itself (though I definitely would not recommend it as your first language to learn), that's not what caused JoeNotCharles' reaction. It's your decision to program directly on top of the Windows API. I've been programming in C++ for years, but I wouldn't do that unless someone paid me a very large sum of money, or put a gun to my head. If you're finding yourself using an ugly API to manually add buttons to your app in code, and tying even handlers to them; you know you're doing something wrong. This is 2008. Even Microsoft doesn't want you to do this anymore. If you know your app only needs to run on Windows, learn C# and program using .NET. It's much more fun, trust me. You'll have your GUI up in no time and you'll be able to focus on coding the stuff that actually matters to you. If you're set on learning C++ right away, start with some console based apps, then move on to learning something like Qt if you want to do GUI apps. As an extra bonus your app will also run on other OSes.
|
# ? Jun 28, 2008 10:55 |
|
Adhemar posted:If you're set on learning C++ right away, start with some console based apps, then move on to learning something like Qt if you want to do GUI apps. As an extra bonus your app will also run on other OSes. And you won't be writing resize handlers manually.
|
# ? Jun 28, 2008 12:33 |
|
That said, a peek into the Windows API is kind of cool. Nice to actually understand what people mean when they say 'message driven' and 'everything is a window'.
|
# ? Jun 29, 2008 04:51 |
|
The Win32 API pretty simple once you get it initially figured out, I like the way it's structured and everything for the most part is well documented on MSDN. Maybe I'm weird, but I much prefer using the API vs something like C#. I love small, fast, native code that I feel like I have complete control over. The last thing a wrote was a little starfield effect in GDI to learn some of it. It compiled to 3.5kb, it needs nothing to run, it even avoids the CRT. If you don't want to create the controls yourself, just use dialogs, or let this generate you some code. http://www.resedit.net/ Maybe in a situation where you need to pound out something fast, I could see the justification, but since I just code for my own amusement, I like this route.
|
# ? Jun 29, 2008 10:04 |
|
slovach posted:The Win32 API pretty simple once you get it initially figured out, I like the way it's structured and everything for the most part is well documented on MSDN. Maybe I'm weird, but I much prefer using the API vs something like C#. Yeah, you're weird. Hello world in Win32. It's almost as bad as X. For reference here's GTK and Qt.
|
# ? Jun 29, 2008 12:50 |
|
vanjalolz posted:That said, a peek into the Windows API is kind of cool. Nice to actually understand what people mean when they say 'message driven' and 'everything is a window'. I was thinking exactly this; I get that I might have chosen a non-standard route that's a lot of extra work, but doing everything "the hard way" has at least taught me how a lot of things work! And like slovach said, I'm just doing this for my own amusement, and I find satisfaction in achieving a lot of things that more serious users of the language would probably regard as trivial and worth delegating to a piece of development software. (Though admittedly it can be frustrating when I can't make them work.)
|
# ? Jun 29, 2008 13:44 |
|
Zombywuf posted:Yeah, you're weird. Hello world in Win32. It's almost as bad as X. For reference here's GTK and Qt. Yeah and here's Hello World in MUMPS: code:
|
# ? Jun 29, 2008 21:09 |
|
Avenging Dentist posted:A "Hello world" program isn't a good indicator of the usability of a language/API. That said, Win32 isn't exactly easy to work with, but at least it's fairly internally consistent. It does drive me a little insane trying to mix the C++ STL with Win32, since Win32 uses capital letters all over the drat place. When you've got to make use of multiple classes and a ton of preprocessor macros to get hello world, something is wrong.
|
# ? Jun 29, 2008 21:53 |
|
What do you guys think of this?
|
# ? Jun 29, 2008 22:39 |
|
Zombywuf posted:Yeah, you're weird. Hello world in Win32. It's almost as bad as X. For reference here's GTK and Qt. You're making it sound more complicated than it is. But if you don't like creating everything yourself, just use a dialog. It'll handle the message loop, creating everything and all that work for you. Couldn't be easier! Creating it yourself is barely more work than this. code:
slovach fucked around with this message at 23:02 on Jun 29, 2008 |
# ? Jun 29, 2008 22:57 |
|
floWenoL posted:What do you guys think of this? The first thing is that it shouldn't be used as an all-purpose C++ coding guide. For instance, Google C++ code does not use exceptions, ever. This makes sense in the context of the performance requirements that Google's production code has, but there are plenty of instances where using exceptions is the better choice for purposes of legibility and maintainability.
|
# ? Jun 29, 2008 23:18 |
|
Zombywuf posted:When you've got to make use of multiple classes and a ton of preprocessor macros to get hello world, something is wrong. Well, it would help if the guy who wrote that tutorial wasn't trying to shoehorn OO stuff into a C library. This is a better example, and even so, the guy is doing a lot more with the WNDCLASSEX structure than is strictly necessary for a Hello world app.
|
# ? Jun 29, 2008 23:38 |
|
Zombywuf posted:When you've got to make use of multiple classes and a ton of preprocessor macros to get hello world, something is wrong. Except that "basic" example of Win32 includes a wrapper class. The Win32 API is a C library so it's obviously going to require some work if you absolutely must make it OO. I actually really like the Win32 API and find it pretty straightforward in the same way that I find C straightforward, but I still don't use it often since I recognize how much easier it is to be productive using .NET, QT, or just about anything else. If I didn't care about being productive I'd write more Win32 API stuff, though. I need some sort of Win32 support group. Smackbilly posted:but there are plenty of instances where using exceptions is the better choice for purposes of legibility and maintainability. Not that I'm agreeing that "don't use exceptions" is good general C++ advice, but there are still some points worth taking home in that section. In particular: quote:Exception safety requires both RAII and different coding practices. Lots of supporting machinery is needed to make writing correct exception-safe code easy. Writing good, exception safe code in C++ is tricky because of the lack of a finally block. Without RAII you end up with either very messy exception handling code all over the place or the potential to leave resources hanging around that should have been cleaned up. It's pretty difficult to get around this for non-trivial programs if you aren't using shared_ptr or another reference counted smart pointer. This also makes it twice as dangerous when someone inexperienced comes along and uses exceptions as an alternate return method or an error flag for non-exceptional conditions.
|
# ? Jun 30, 2008 02:47 |
|
floWenoL posted:What do you guys think of this? There's some stylistic issues I don't agree with that people have been arguing about for 30 years (wtf uses 2 spaces) but other than that I think it's pretty sane. Some day I'll post the tale of mustDeref() and make you all converts.
|
# ? Jun 30, 2008 02:48 |
|
more falafel please posted:There's some stylistic issues I don't agree with that people have been arguing about for 30 years (wtf uses 2 spaces) but other than that I think it's pretty sane. I never understood people who advocate spaces in general. Tabs for indenting, spaces for vertical alignment. It's not hard to format code that's portable to different tab-widths. Also the "no using in .cc files" rule is laffo. That's pretty much the only place you should have using declarations.
|
# ? Jun 30, 2008 02:54 |
|
Avenging Dentist posted:Also the "no using in .cc files" rule is laffo. That's pretty much the only place you should have using declarations. I understand it. They also say to eschew abbreviations in naming. using declarations are just abbreviations, really. I'm not saying I particularly like it, but I don't really have an opinion.
|
# ? Jun 30, 2008 03:18 |
|
Avenging Dentist posted:Also the "no using in .cc files" rule is laffo. That's pretty much the only place you should have using declarations. The wording is confusing, but if you expand the arrow, it explains that you are allowed to use using in .cc files. And yes, for anyone who isn't aware, the arrows do something, namely provide more details.
|
# ? Jun 30, 2008 03:26 |
|
floWenoL posted:What do you guys think of this? Personally I think this is disgusting: code:
The indentation also bothers me. I would much rather have lines move to the right the farther I read into the function, rather than the weird shifting going on here. I also don't like the bit on function naming. It seems like it could introduce inconsistencies if there isn't a direct relationship between public characteristics and internal implementation variables. Edit: I'd be interested in hearing what the rest of you think about the section on streams in particular. Not just for Google's case (where they need to maintain consistency with old code) but for general practice programming. The guide seems to dismiss the issue as "they both have pros and cons, so either one is just as good." Dransparency fucked around with this message at 04:35 on Jun 30, 2008 |
# ? Jun 30, 2008 04:28 |
|
floWenoL posted:What do you guys think of this? I just skimmed and it's not bad, but some stuff I do disagree with. I will probably make it sound worse than it is because I get really upset when people give foolish rationales, but really nothing in here is horrible. quote:All inheritance should be public. If you want to do private inheritance, you should be including an instance of the base class as a member instead. In modern C++ there are lots of reasons to prefer private inheritance rather than datamembers in certain situations, some of which are techniques that simply only work with inheritance as opposed to composition. For one, private inheritance is useful for minimizing redundancy by inheriting from a base and pulling in desired names with a using declaration rather than having to tediously create I.E. forwarding functions (which can be error prone and less efficient if not done carefully, not to mention potentially less clear). Another example is helper bases that pull in functions that can be looked up via ADL (I.E. Boost.Operators). As well, using inheritance let's you take advantage of the empty base optimization, which as a side note, is exactly how Boost compressed pair works which is on this list's approved Boost libraries -- the only approved component of Boost on the list actually (so basically the guide doesn't want you to do private inheritance, but it's okay to use it indirectly, which stinks of Java's operator + logic to me). quote:Only very rarely is multiple implementation inheritance actually useful. We allow multiple inheritance only when at most one of the base classes has an implementation; all other base classes must be pure interface classes tagged with the Interface suffix. quote:Use 0 for integers, 0.0 for reals, NULL for pointers, and '\0' for chars. quote:Do not overload operators except in rare, special circumstances. This I disagree with entirely. First, I don't understand this talk about people expecting operations to be "cheap" (or even what the vague term of "cheap" means in the general sense). You expect the operation to do what it's supposed to do, and if there is a required complexity for a given domain at concept then it should be made known. Multiplying two matrices might be expensive, but it's still a multiplication operation. Concatenating strings with + is intuitive. Anyone who somehow thinks that using a named function called "multiply" does anything other that make you type more and make it harder for your object to be used in generic code is simply not used to a language with operator overloading and that's it. There is nothing special about operators that makes them any different from other operations other than syntax and this whole nonsensical idea of them having to be "cheap" is just silly. As well, the comment "Foo + 4 may do one thing, while &Foo + 4 does something totally different" really just blows my mind in that I can't believe somebody genuinely thinks this is a good point. Are they trying to tell me that at some point in code somebody honestly accidentally wrote &Foo + 4 instead of Foo + 4, and after doing that, it somehow bit them in the rear end rather than being caught by the compiler? Are they also missing out on the point that what they are saying would be true of integers and the built-in operator +? Maybe they are suggesting that people should use a named "Add" operation for built-in arithmetic types as well, since that goes along with their argument? Anyway, aside from that being an odd mistake to make to begin with and the fact that their "rationale" would apply to built-in operators, the expression given would likely never occur alone like that in a statement as it would be a part of a larger expression, since unless the + expression they showed has side-effects, you'd be losing any calculation being made anyway (and if the statement has no side effects, that typo would generally make no difference since there is no observable change either way, though you technically might get undefined behavior with the &Foo + 4 depending on context, but even I'll say that's a moot point and I'm a pretty pedantic language lawyer). Anyway, getting back to what this means -- this "&Foo + 4" expression will be a sub-expression of something else, for instance, you'd store the result of the plus operation in another object or pass the result to a function. C++ is a statically-typed language, so unless the rest of the expression can take a pointer as an argument or an object of whatever the result type of the + is here, you'd get a compiler error so you'd know your mistake right away! I find it extremely hard to believe that anything like what they described has or ever will occur in any competent [or incompetent] person's code. The fact is, using + makes perfect sense here for built-in arithmetic types, pointer types, and user-defined types. Barring contrived examples that don't even make sense, you have to really push to come up with sound reasons against them as opposed to being driven by blind, religious issues with operator overloading. Finally, they claim that overloading the assignment operator is bad as well along with the equality operator. I find it extremely hard to believe that using "Equals" instead of "==" is more clear or less error prone. Again, all I see it accomplishing is making it harder to have your objects work in generic code and making it seem like operators are some special devices that are only for use with built-ins. Their excuse that it makes it easier to search for in code is also very weak considering all you're doing is weeding out built-in operations, whereas if all of your user-defined types use the same name (I.E. Equals) you have the same exact "problem" (which I can't even really see as being a problem to begin with). All of their issues with operators are extremely contrived and sound like worries that people might have if they worked their whole life in another language and got an idea stuck in their head of what they personally think an operator should be as opposed to what operators really are, at least with respect to C++. quote:All parameters passed by reference must be labeled const. This is C++. You can pass objects as references, that's how the language works. Using non-const references for parameters which modify an object as opposed to a pointer is the preferred C++ way of having functions which modify arguments as it removes the issue of making it unclear about the handling of null pointers and overall it simplifies syntax. If it is unclear that an argument to a function should take a non-const reference then that is generally a poorly named function and/or the person trying to use it doesn't understand it's purpose, which either way is a programmer error. The only time I see people have issues with this are when they come from a C background where references just didn't exist so they just got used to always passing out parameters by pointer. There is a better solution in C++ so use it and stop clinging to an out-dated C-style approach. quote:If you want to overload a function, consider qualifying the name with some information about the arguments, e.g., AppendString(), AppendInt() rather than just Append(). This is just silly. Again, they all correspond to the same logical operation and having to repeat the type of your expression just to call the function is redundant, not to mention annoying. You also just once again make it harder to use the function in generic code. quote:We do not allow default function parameters. quote:You should not use the unsigned integer types such as uint32_t, unless the quantity you are representing is really a bit pattern rather than a number. In particular, do not use unsigned types to say a number will never be negative. Instead, use assertions for this. Edit: I don't know why you're getting all upset about naming and indentation, etc. You can't really fault anyone for something that's nearly entirely a subjective choice. That Turkey Story fucked around with this message at 08:30 on Jun 30, 2008 |
# ? Jun 30, 2008 08:27 |
|
|
# ? May 18, 2024 02:05 |
|
That Turkey Story posted:Well put.
|
# ? Jun 30, 2008 08:44 |