473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

programming style for windows apps

I'm wondering if anyone knows where I can learn a good programming
method for creating windows apps. I'm just starting to learn windows
programming with MSVC++ 6.0. I want to learn low level windows
programming in C first. I don't want to learn any bad habits by
hacking away at code until I get something to work.

Specifically, I'd like to learn how to set up and plan out a C windows
project and break it down into pieces of code that will be efficient
and in good style. A recomendation for website or book that teaches C
windows methodolgy would be good.

I hope the question was clear.

-thanks
-todd
Nov 13 '05 #1
8 2365
sm*****@auburn.edu (Todd Smith) wrote in
news:ed**************************@posting.google.c om:
I'm wondering if anyone knows where I can learn a good programming
method for creating windows apps. I'm just starting to learn windows
programming with MSVC++ 6.0. I want to learn low level windows
programming in C first. I don't want to learn any bad habits by
hacking away at code until I get something to work.

Specifically, I'd like to learn how to set up and plan out a C windows
project and break it down into pieces of code that will be efficient
and in good style. A recomendation for website or book that teaches C
windows methodolgy would be good.

I hope the question was clear.


Very. And very off-topic here. You seek a software engineering newsgroup
and one of the microsoft.* newsgroups. Please read the C-FAQ.

--
- Mark ->
--
Nov 13 '05 #2

"Todd Smith" <sm*****@auburn.edu> wrote in message
I'm wondering if anyone knows where I can learn a good programming
method for creating windows apps.

Windows programming isn't topical here but good style is.
For any program, you want to break the source down into logical units. For a
Windows program, an obvious unit is the Window.
Windows allows you to hang a pointer containing arbitrary data off each
window. Use this as something technically called an "object".

Eg, say you have a window which goes darker as you left click it, and
lighter as you right click it. It might be a control for ambient light level
in a game, for example.

You would define a structure

typedef struct
{
unsigned char level; /* light level 0-255 */
unsigned char prev; /* previous level (to implement a cancel) */
/* maybe more members here */
}LIGHTLEVEL;

Then in your windows procedure, the very first line retrieves this structure
from the window.

You then have a series of sub-functions to respond to messages. A "draw"
message would floodfill the window with grey of the appropriate colour.
Left-clicks and right clicks would cause the level to change and send a
redraw message. You might also want to respond to resize messages.

Nov 13 '05 #3
Malcolm wrote:

"Todd Smith" <sm*****@auburn.edu> wrote in message
I'm wondering if anyone knows where I can learn a good programming
method for creating windows apps.
Windows programming isn't topical here but good style is.


Let's rephrase the question:

"I have a C function which accepts four parameters. It's a key routine, a
gateway into the whole program. The parameters convey information about an
incoming message, and I have tons of different messages to process. How can
I invoke the right bits of my program without making a complete pig's
breakfast of the program structure?"

I think that, put this way, it is very close to becoming a C question. YMMV.

For any program, you want to break the source down into logical units. For
a Windows program, an obvious unit is the Window.
Windows allows you to hang a pointer containing arbitrary data off each
window. Use this as something technically called an "object".
Well, I call it a pointer to struct, but yeah, this is good advice.
Eg, say you have a window which goes darker as you left click it, and
lighter as you right click it. It might be a control for ambient light
level in a game, for example.

You would define a structure

typedef struct
{
unsigned char level; /* light level 0-255 */
unsigned char prev; /* previous level (to implement a cancel) */
/* maybe more members here */
}LIGHTLEVEL;

Then in your windows procedure, the very first line retrieves this
structure from the window.

You then have a series of sub-functions to respond to messages. A "draw"
message would floodfill the window with grey of the appropriate colour.
Left-clicks and right clicks would cause the level to change and send a
redraw message. You might also want to respond to resize messages.


This is just about a perfect description of how I write Windows programs. I
would just add that I handle each message via a function with the same
prototype as the "standard" window procedure. This makes "message cracking"
very easy indeed. In fact, I use a macro to associate messages with
functions. My window procedures contain one physical line per message, plus
about half a dozen lines of overhead.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #4
Richard Heathfield wrote:
I would just add that I handle each message via a function
with the same prototype as the "standard" window procedure.
This makes "message cracking" very easy indeed.
In fact, I use a macro to associate messages with functions.
My window procedures contain one physical line per message,
plus about half a dozen lines of overhead.


I like an array of function pointers
for handling numbered messages.

--
pete
Nov 13 '05 #5
pete wrote:
Richard Heathfield wrote:
I would just add that I handle each message via a function
with the same prototype as the "standard" window procedure.
This makes "message cracking" very easy indeed.
In fact, I use a macro to associate messages with functions.
My window procedures contain one physical line per message,
plus about half a dozen lines of overhead.


I like an array of function pointers
for handling numbered messages.


Now there's an idea. :-)

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #6

Richard Heathfield <in*****@address.co.uk.invalid> wrote in message
news:3f******@news2.power.net.uk...
pete wrote:
Richard Heathfield wrote:
I would just add that I handle each message via a function
with the same prototype as the "standard" window procedure.
This makes "message cracking" very easy indeed.
In fact, I use a macro to associate messages with functions.
My window procedures contain one physical line per message,
plus about half a dozen lines of overhead.


I like an array of function pointers
for handling numbered messages.


Now there's an idea. :-)


Until you actually look at the numerical values
of the e.g. MS Windows messages. The array would
be *very* large. :-)

-Mike

Nov 13 '05 #7
Mike Wahler wrote:
Richard Heathfield <in*****@address.co.uk.invalid> wrote in
message news:3f******@news2.power.net.uk...
pete wrote:
Richard Heathfield wrote:

I would just add that I handle each message via a
function with the same prototype as the "standard"
window procedure. This makes "message cracking" very
easy indeed. In fact, I use a macro to associate
messages with functions. My window procedures contain
one physical line per message, plus about half a dozen
lines of overhead.

I like an array of function pointers for handling numbered
messages.


Now there's an idea. :-)


Until you actually look at the numerical values of the e.g. MS
Windows messages. The array would be *very* large. :-)


But surely /never/ larger than 640K...
;-|

--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c

Nov 13 '05 #8
Mike Wahler wrote:

Richard Heathfield <in*****@address.co.uk.invalid> wrote in message
news:3f******@news2.power.net.uk...
pete wrote:
> Richard Heathfield wrote:
>
>> I would just add that I handle each message via a function
>> with the same prototype as the "standard" window procedure.
>> This makes "message cracking" very easy indeed.
>> In fact, I use a macro to associate messages with functions.
>> My window procedures contain one physical line per message,
>> plus about half a dozen lines of overhead.
>
> I like an array of function pointers
> for handling numbered messages.


Now there's an idea. :-)


Until you actually look at the numerical values
of the e.g. MS Windows messages. The array would
be *very* large. :-)


Well, not necessarily. You could easily map them: unsigned int
MapMessageToFunction(MESSAGE m); Having said that, it does become less
tempting if you have to do that, since that's basically what the switch
does anyway.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: tjones | last post by:
Hi, I am guessing this is *THE* nntp newsgroup for C#? I was hoping someone could point me in the right direction. Id like to find employment in the IT industry as a programmer again. My...
3
by: Siddharth Jain | last post by:
Hello, Could someone please tell me the history of GUI programming for windows. In the early days, we had to write 100s of lines of code to make a simple dialog box. Then along came MFC to...
36
by: peter.mosley | last post by:
I am trying to learn GUI programming in Python, but have to confess I am finding it difficult. I am not an experienced programmer - just someone who from time to time writes small programs for...
7
by: Charles | last post by:
I'd like to develop a simple cross-platform application in C++. I'd like it to run in Windows, OS X, PC-BSD and Linux. From my research, it seems I should use Qt or Gtk as a graphical library. Do...
2
by: Giggle Girl | last post by:
Hello there! I am a User Interface Designer at a company that only makes web apps. I am fluent in HTML, Javascript and Graphics programs. Now we are making a compiled app with VS05 in C#, and I...
38
by: ifti_crazy | last post by:
I am VB6 programmer and wants to start new programming language but i am unable to deciced. i have read about Python, Ruby and Visual C++. but i want to go through with GUI based programming...
14
by: deko | last post by:
For building Windows desktop apps, the clear favorite is C#. But my clients can't afford to buy Microsoft products. So I need to develop software for Linux users and web applications. In the...
1
by: hesamjamei | last post by:
Hello!! I am just about to break my computer...... Is a Window Programming issue .....compiler errors are as below : 1>------ Build started: Project: Project 78, Configuration: Debug Win32...
2
by: Netwatcher | last post by:
Hello, i am new to c++ windows and DX programming, i encountered a code in the book stated in the title, which doesn't work for a reason, here is the code // Beginning Game Programming // Chapter...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.