William Hemsworth 1,339 Posting Virtuoso

When calling a function, you don't have to but the type it returns before it.

For example, change line 23 to:

calcAverage(score1, score2, score3);

Hope this helps.

William Hemsworth 1,339 Posting Virtuoso

A friend showed me this :) [link]

William Hemsworth 1,339 Posting Virtuoso

What's the big deal? If you just use a library, it's easy. [link]
This worked perfectly for me, and there's plenty more out there.

William Hemsworth 1,339 Posting Virtuoso

When changing my avatar, 70/80% of the time it gives me the same error. After refreshing a few times and trying again, it works. Get's quite irritating (hense my no avatar :P)

William Hemsworth 1,339 Posting Virtuoso

Why? For once, tell us why you think this code is wrong instead of leaving a piece of sh*t comment and then run and hide when you get a reply.

Just not worth it anymore. People have already complained about him by asking for a ban, but he isn't "breaking" any rules. People can judge that his posts are awful just by looking at his reputation, so I'll just try my best to ignore him from here on.

William Hemsworth 1,339 Posting Virtuoso

On Visual Studio, you do this:

1. To the right green "run" button, set the compile state to "Release"
2. Go to the menu "Project -> (project name) properties"
3. Under "Configuration Properties -> C/C++ -> Code Generation", set "Runtime library" to "Multi-threaded (/MT)"

This is what I found to be the most portable configurations.

William Hemsworth 1,339 Posting Virtuoso

Hmmm... does make one think. Does not that turn the "donation" into a "subscription fee"? Not against subscriptions, but all for calling things what they truly are.

Well, the money helps to keep the site running, and to try and get as many people as possible to donate, they give them as many advantages as possible to convince you to do it too. After all, to solve your problem, aaaaall you need to do is donate! :)

William Hemsworth 1,339 Posting Virtuoso

Or be a member since the time that animated-avatars were still allowed and never change it, like I did. (yes it is animated) :)

Heh, I actually noticed the blink quite some time ago.
I think samaru took full advantage of the old default restrictions :P with a 120px x 120px avatar.

Also, in Area 51, John A complains about the same thing you did here kaninelupus, but he never got a reply.

William Hemsworth 1,339 Posting Virtuoso

Keep to one forum, please. [link]

Salem commented: Wait, there's more! +36
William Hemsworth 1,339 Posting Virtuoso

You're better off just doing these things manually, trust me. It's 100x more work to make this bot than it is to just do it yourself.

William Hemsworth 1,339 Posting Virtuoso

I would probably miss my mp3 player more, I spent a long time customizing it to be exactly how i want :) My phone I would miss, but I could still use the phone I won from a crane machine (still can't believe I finally managed it).

William Hemsworth 1,339 Posting Virtuoso

Donate :)

William Hemsworth 1,339 Posting Virtuoso

It's obviously fake/fixed otherwise he would be living a jet-set lifestyle.

Either way, he pulled off a good trick on live TV. He has a good history for these sort of predictions, like here. [link]

You can't understand how he manages to predict which horse wins for several games in a row, but 'The System' all makes sense at the end. It's a very interesting episode. I wouldn't be surprised if he used a clever method to predict the lottery too, as he claims he's done nothing illegal.

I'll find out tomorrow I guess :P

William Hemsworth 1,339 Posting Virtuoso

Nice well programmed snippet.

William Hemsworth 1,339 Posting Virtuoso

What did he JUST tell you!

Read rules at daniweb.

Use code-tags.

Salem commented: <agent smith>it is inevitable</agent smith> +36
William Hemsworth 1,339 Posting Virtuoso

Get a hobby. Play a sport, learn a language, make some friends, try anything new and generally accept opportunities that come to you :P [link] and watch that film :D

William Hemsworth 1,339 Posting Virtuoso

Ugh, where to begin.

1. Don't use turbo C++, it's ancient. Go for a more modern compiler.
2. Don't use conio.h, it's not standard.
3. We aren't going to do your homework for you.

William Hemsworth 1,339 Posting Virtuoso

Just watched this on TV under an hour ago.
http://www.youtube.com/watch?v=cHZ2mQczkcg

It was amazing. We switched to the channel the lottery was on, and both were live. He managed to predict the results perfectly. I don't think he used any illusions, but I will be very interested to see how he pulled off such a trick when he says how he did on friday.

Anybody got any ideas as to how you think he did it? :P

William Hemsworth 1,339 Posting Virtuoso

Stop this spamming with fake question/answer and complete noob and wrong code (original code from MSDN has been posted 15 years ago !)
Read the Petzold to learn Windows programming.

Oh, shut up.
He provided a good link, you didn't.

Nick Evan commented: Yes! +29
William Hemsworth 1,339 Posting Virtuoso

This code is wrong.
Initializing is missing and then it won't work on some OS SP...

Fix it for me then, genius.

William Hemsworth 1,339 Posting Virtuoso

It means it's an unsigned integer, to match the type of value.

Found from the web:

u8 unsigned byte (8 bits)
u16 unsigned word (16 bits)
u32 unsigned 32-bit value
u64 unsigned 64-bit value
s8 signed byte (8 bits)
s16 signed word (16 bits)
s32 signed 32-bit value
s64 signed 64-bit value

There's more, but I'm sure you get the picture.

William Hemsworth 1,339 Posting Virtuoso

I cant place code here, becasuse this happens in more than one diferent project. When processor is 100 % working, icon is not shown and that's the problem. I found that it is problem with microsoft. I am only interested id someone does not figured it in his own way

Maybe you're doing it wrong in every project?

William Hemsworth 1,339 Posting Virtuoso

How do you view all code snippets by one particular person? I can't find it :\
I used that occasionally.

William Hemsworth 1,339 Posting Virtuoso

They're coming up everywhere, I've seen many questions marked as code snippets in the C++ forum, and just spotted this one.

It's definitely causing a lot of confusion.

William Hemsworth 1,339 Posting Virtuoso

No idea about uploading files, but as for downloading a file, here's an example of how to download a picture of a kitten.

#include <windows.h>
#pragma comment(lib, "urlmon.lib")

int main() {
  char url[] = "http://felixgilman.com/wordpress/wp-content/uploads/2008/04/kitten.jpg";
  char savename[] = "kitten.jpg";
  URLDownloadToFile( NULL, url, savename, 0, NULL );
}

Just search the internet a bit, i'm sure you will figure it out.

William Hemsworth 1,339 Posting Virtuoso

Hell, I can't remember :D

I started off with flash AS2 when I was like.. 11 years old.
At 13 years old, I read a few books on C++, and started getting the hang of it.
The first "useful" C++ program I can actually remember making is one that converts miles to kilometers.

William Hemsworth 1,339 Posting Virtuoso

Perhaps by learning C++ and a graphics library first.
This forum is more meant for specific problems, resources are all over the web for this kind of problem. [link]

Also, no need for the poll.

William Hemsworth 1,339 Posting Virtuoso

You mean you want to know if the button is enabled or disabled?
If so that's easy, here's what i came up with after a couple of minutes of playing around with the windows api.

bool enabled = !(bool)(GetWindowLong( button, GWL_STYLE ) & WS_DISABLED);

Hope this helps.

Salem commented: Very nice +36
tux4life commented: I agree on the fact that you're a WinAPI God :) +21
William Hemsworth 1,339 Posting Virtuoso

You could start off by NOT SHOUTING.
If you get the handle of that window, using simple Win32 API, you can call GetWindowText.

kvprajapati commented: Well said. +13
William Hemsworth 1,339 Posting Virtuoso

Is there too much code to post the whole thing, so i can try and compile exactly what you've got? I'm sure I could solve it if i could compile it.

William Hemsworth 1,339 Posting Virtuoso

Show us your code so far, so we can help then.

William Hemsworth 1,339 Posting Virtuoso

For example, the code to send CTRL-G is this:

keybd_event(VK_CONTROL, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(71, 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(71, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);

Hope this helps.

William Hemsworth 1,339 Posting Virtuoso

Thanks a lot. :)

I'm still having a few minor problems tho'.

I need to send a ctrl+g

SendMessage ( hndDesigner, WM_KEYDOWN, 17, 1) ;            
	SendMessage ( hndDesigner, WM_KEYDOWN, 71, 1) ;            
	SendMessage ( hndDesigner, WM_KEYUP, 71,  0xC0000001 ) ;    
	SendMessage ( hndDesigner, WM_KEYUP, 17, 0xC0000001 ) ;

17 = control
71 = 'g'

Doesn't work?
I uses a spy so I'm sure that I have the right handle, but nothing happens :/

Any ideas?

Thanks,
- Henning

Instead of sending a message to press a key, try actually simulating a keypress or mouse click to achieve the same result, research mouse_event and keybd_event.

William Hemsworth 1,339 Posting Virtuoso

*Yawn*

Once again, instead of saying what not to do or what's wrong in his program, tell him how to do it right, then we all might actually think you know something for once. Otherwise, just go away, your "help" is needed here.

or *Isn't, should I say :P

William Hemsworth 1,339 Posting Virtuoso

Well, isn't that a letdown :( I like how you can see the visitors to your profile though :)

This update is full of surprises, good and bad.

William Hemsworth 1,339 Posting Virtuoso

Don't copy MSDN doc.
And it's not the right method (events)

*Yawn*

Once again, instead of saying what not to do or what's wrong in his program, tell him how to do it right, then we all might actually think you know something for once. Otherwise, just go away, your "help" is needed here.

William Hemsworth 1,339 Posting Virtuoso

> I really like the 'edit history' functionality :)
Huh? Where?

William Hemsworth 1,339 Posting Virtuoso

I noticed it's faster.

William Hemsworth 1,339 Posting Virtuoso

Good Snippet.

William Hemsworth 1,339 Posting Virtuoso

Nice snippet, works perfectly. The only thing I could complain about (other than the formatting) is the fact that you included conio.h.

William Hemsworth 1,339 Posting Virtuoso

Rofl :]

William Hemsworth 1,339 Posting Virtuoso

Good Work.

William Hemsworth 1,339 Posting Virtuoso

Here's how I would have done it:

#include <iostream>
using namespace std;

int main() {
  char binary[33]; // 32bit + '\0'
  unsigned int decimal = 0;

  cout << "Enter binary:\n> ";

  cin.getline( binary, 32 );
  unsigned int exp = 1;

  for (int i = (int)strlen( binary ) - 1; i >= 0; --i) {
    if ( binary[i] == '1' )
      decimal += exp;

    exp <<= 1;
  }

  cout << "\nDecimal:\n> " << decimal;

  cin.ignore();
}
William Hemsworth 1,339 Posting Virtuoso

Obviously only works with ascii and doesn't support unicode, otherwise char* would have been used. Either way, using the toupper function there outputs: RÚSUMÚ for me (even though it's most probably just a font problem). I would rather it printed RéSUMé :] Both these codes simply turn any characters between 'a' to 'z' and makes them uppercase.

William Hemsworth 1,339 Posting Virtuoso

Shorter, but perhaps not any more efficient.

void stoupper(char *s) {
  do if (96 == (224 & *s)) *s &= 223;
  while (*s++);
}

Wow, I'm competitive. No doubt there's some mistake in mine though.

Here's how it works:

the first lowercase letter 'a' has a binary of: 01100001
the last lowercase letter 'z' has a binary of: 01111010

Both these letters have 01100000 in common.
But if the bit 10000000 is on, then it cant be a letter.

So by doing an AND check with 11100000 and comparing (==) it with the value 01100000, it should determine whether or not the character is a valid lowercase letter.

Then remove the bit 00100000 to make the character a capital.

Am I good or what? :D

William Hemsworth 1,339 Posting Virtuoso

Good simple snippet :)

William Hemsworth 1,339 Posting Virtuoso

If this is a competition to make the smallest code, then this wins :P

while (*s1++ = *s2++);
William Hemsworth 1,339 Posting Virtuoso

This snippet basically shows you how to input a password from the user without actually displaying the characters, instead they are replaced with the ' * ' character as you type.

The code is uncommented, so I will briefly explain it.

This function: void PasswordInput(char *password, size_t maxLength) has two parameters, the first one is a pointer to a buffer containing enough free space to input up to maxLength number of characters.

William Hemsworth 1,339 Posting Virtuoso

Well, you could use the isalpha function, but i'm also using the character as an index for an array, so it's just as simple to do it this way.

William Hemsworth 1,339 Posting Virtuoso

Thank you :]