Quantcast

Maximum PC

It is currently Sun Dec 28, 2014 5:55 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Help with the windows 32 API
PostPosted: Wed Jan 14, 2009 5:07 pm 
Team Member Top 500
Team Member Top 500
User avatar

Joined: Mon Jan 08, 2007 1:41 pm
Posts: 2033
I've begun casually delving into windows GUI programming. I taught myself a lot of C/C++ over the past year and have wanted to move on. I saw this as the next logical step.

It has generally been my tendency to not necessarily follow perfect form while programming. With that said, concerning variable declarations when writing a windows program:

1. Is it completely necessary to use the windows forms of ints and chars? i.e. (PCHAR, LPCH, PCH, NPSTR, etc.). I can understand how I would use these types for the GUI portion, but must the rest of my code feature them? All the fancy windows stuff is just typedef'd as the corresponding ints and chars (not counting the double width chars).

2. The windows API is based on C, but I have found that I can compile everything without hassle using a .cpp source file and a c++ compiler. Is this taboo in the world of programming? Will adding a GUI in C to a program that uses c++ libraries and functions cause problems down the road? (Assuming it compiles and runs fine)

3. Advice/tips on writing GUIs? I found a free resource editor called ResEd, and I'm using DevC++. I didn't see the point of MS Visual Studio because it doesn't support resource file generation, and as far as I know, I wasn't able to add my own.

4. Having some other problems. Read on to see.

Thanks for any comments
qa9b


Last edited by qa9b on Wed Jan 14, 2009 6:49 pm, edited 1 time in total.

Top
  Profile  
 
 Post subject:
PostPosted: Wed Jan 14, 2009 5:30 pm 
Little Foot
Little Foot
User avatar

Joined: Mon Jul 28, 2008 1:39 pm
Posts: 123
I can answer your second question...
Since, as you probably know, C++ was developed as an extension to C, any C++ compiler worth its salt will compile C source code with no problem. I think this is actually fairly common, i.e., you only need one compiler for both languages, which is pretty convenient.


Top
  Profile  
 
 Post subject:
PostPosted: Wed Jan 14, 2009 6:16 pm 
Team Member Top 500
Team Member Top 500
User avatar

Joined: Mon Jan 08, 2007 1:41 pm
Posts: 2033
Quertior wrote:
I can answer your second question...
Since, as you probably know, C++ was developed as an extension to C, any C++ compiler worth its salt will compile C source code with no problem. I think this is actually fairly common, i.e., you only need one compiler for both languages, which is pretty convenient.


Thanks for the reply.

I was just working on the first example program in the book I decided to buy. I was having a little trouble compiling it. Neither DevC++ or Visual studio were doing it, until I decided to make a "windows application" instead of an "empty project" in devc++.

I found that a bit odd. What is the difference between a windows app and an empty project in devc++? I checked all the compiler configuration options and they seemed to be all the same.


Top
  Profile  
 
 Post subject:
PostPosted: Wed Jan 14, 2009 6:39 pm 
Team Member Top 500
Team Member Top 500
User avatar

Joined: Mon Jan 08, 2007 1:41 pm
Posts: 2033
Okay, new priority. DevC++ still isn't compiling stuff correctly. It's giving me linker errors:

Image

When I began this, I chose "windows application" in the devc++ new project menu. It gave me the basic structure, I added the WM_CREATE case with the PlaySound command. Obviously I included windows.h

Seems the linker can't find the PlaySound function? It was doing the same thing with GetStockObject earlier, but that seems to work now.

The free borland command line compiler.... compiles the exact same code without problems. How do I make DevC++ stop being a bitch and compile my damn code?

Help? Jip?

:cry:


Top
  Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2009 5:12 am 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Does DevCpp know where to find Windows.h? That could be your main problem. If you can upload a zip of the project somewhere I might be able to help you out.

It is often hard to debug that stuff without being in front of it.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2009 5:21 am 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24238
Location: Granite Heaven
qa9b wrote:
Help? Jip?

:cry:


Sorry bud .. I've done almost no Win32 development in the last .. oh .. 8 years or so. :(


Top
  Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2009 1:04 pm 
Team Member Top 500
Team Member Top 500
User avatar

Joined: Mon Jan 08, 2007 1:41 pm
Posts: 2033
Jipstyle wrote:
qa9b wrote:
Help? Jip?

:cry:


Sorry bud .. I've done almost no Win32 development in the last .. oh .. 8 years or so. :(


Haha, shot in the dark. AFAIK it hasn't changed much in the past eight years.

CrashTECH wrote:
Does DevCpp know where to find Windows.h? That could be your main problem. If you can upload a zip of the project somewhere I might be able to help you out.

It is often hard to debug that stuff without being in front of it.


Thanks for the offer. Like I said, my borland command line compiler does it fine, but DevC++ has problems. Here's a link to a zip file with the source code and the devc++ project file I was using:

http://www.brianapache.homedns.org/public/hellowin.zip

The only functions I added to the default win 32 code are GetStockObject and PlaySound. I assume you're opening this in devc++, that's where I'm having issues.

Thanks again for the replies
qa9b


Top
  Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2009 1:08 pm 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
I will check it out when I get home. FWIW, DevCpp is like 8 years old?


Top
  Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2009 3:39 pm 
Team Member Top 500
Team Member Top 500
User avatar

Joined: Mon Jan 08, 2007 1:41 pm
Posts: 2033
CrashTECH wrote:
I will check it out when I get home. FWIW, DevCpp is like 8 years old?


That may be the case, but from the look of devcpp's download page new updates are released periodically. I just realized I'm running version 4.9.9.2 and the version 5 beta is now out. I can try upgrading and see if that helps. The borland command line compiler I used is at least 8 years old, so I'm not so sure age has anything to do with it.

When I'm typing out the PlaySound function, devcpp pops up with the argument list as usual... so it seems to me that it knows where to find the definitions of the win32 library functions.

I also had little success with compiling that code in VS Express 2008, but I really haven't looked into that too much.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2009 4:09 pm 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
There aren't any dates there... but trust me, it is old :)

The last release was Feb of 2005, so it is almost 4 years old now.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2009 4:13 pm 
Little Foot
Little Foot
User avatar

Joined: Mon Jul 28, 2008 1:39 pm
Posts: 123
And you said that VC++ won't compile it either? Wierd. After I eat lunch I'll see if i can compile it, I don't have much Win32 dev experience though :(


Top
  Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2009 4:24 pm 
SON OF A GUN
SON OF A GUN
User avatar

Joined: Mon Nov 01, 2004 5:41 am
Posts: 11605
Okay, I got it.

You need to do this:
http://forums.devshed.com/showpost.php? ... stcount=13

Quote:
In Dev-C++:

Project -> Project Options -> Paramters

In the text box labeled 'Linker', add the flag:
Code:
-lwinmm
That will make it link against the proper library to define the PlaySound function.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2009 5:10 pm 
Team Member Top 500
Team Member Top 500
User avatar

Joined: Mon Jan 08, 2007 1:41 pm
Posts: 2033
CrashTECH wrote:
Okay, I got it.

You need to do this:
http://forums.devshed.com/showpost.php? ... stcount=13

Quote:
In Dev-C++:

Project -> Project Options -> Paramters

In the text box labeled 'Linker', add the flag:
Code:
-lwinmm
That will make it link against the proper library to define the PlaySound function.


Wow, crash, great find!!

So I guess my troubles are limited to the playsound function? I was worried that the problem was more than just one function.

Did you by any chance come across info about what linking "winmm" does besides make playsound work? Any other libraries I must link that correspond to windows API functions?


Top
  Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2009 5:16 pm 
Team Member Top 500
Team Member Top 500
User avatar

Joined: Mon Jan 08, 2007 1:41 pm
Posts: 2033
Ignore those questions I just asked! It says include winmm right on the frickin msdn page I linked to earlier! whoops :oops:


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

© 2014 Future US, Inc. All rights reserved.