Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,155 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,121 people online right now. Registration is fast and FREE... Join Now!




very quick question

2 Pages V  1 2 >  
Reply to this topicStart new topic

very quick question

Clearman
16 Dec, 2007 - 05:03 PM
Post #1

New D.I.C Head
*

Joined: 13 Dec, 2007
Posts: 48


My Contributions
I know this question is out of the norm but when you program do you have notes or do you just memorize the mandatory lines of code needed .For Example how would you type out this code?
CODE


#include <windows.h>


const char *ClsName = "BitmapLoading";
const char *WndName = "Easy bitmaploading!";



LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);




INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
               LPSTR lpCmdLine, int nCmdShow)
{
    MSG        Msg;
    HWND       hWnd;
    WNDCLASSEX WndClsEx;

    
    WndClsEx.cbSize        = sizeof(WNDCLASSEX);
    WndClsEx.style         = CS_HREDRAW | CS_VREDRAW;
    WndClsEx.lpfnWndProc   = WndProcedure;
    WndClsEx.cbClsExtra    = 0;
    WndClsEx.cbWndExtra    = 0;
    WndClsEx.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    WndClsEx.hCursor       = LoadCursor(NULL, IDC_ARROW);
    WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    WndClsEx.lpszMenuName  = NULL;
    WndClsEx.lpszClassName = ClsName;
    WndClsEx.hInstance     = hInstance;
    WndClsEx.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

    RegisterClassEx(&WndClsEx);

    
    hWnd = CreateWindow(ClsName,
              WndName,
              WS_OVERLAPPEDWINDOW,
              CW_USEDEFAULT,
              CW_USEDEFAULT,
              CW_USEDEFAULT,
              CW_USEDEFAULT,
              NULL,
              NULL,
              hInstance,
              NULL);
    
    
    if( !hWnd ) // If the window was not created,
    {
        MessageBox(NULL, "The window is not created because errors in the program", "Error!", MB_OK);
        return 0;
    }    

    ShowWindow(hWnd, SW_SHOWNORMAL);
    UpdateWindow(hWnd);

    while( GetMessage(&Msg, NULL, 0, 0) )
    {
             TranslateMessage(&Msg);
             DispatchMessage(&Msg);
    }

    return Msg.wParam;
}




LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,
               WPARAM wParam, LPARAM lParam)
{
    switch(Msg)
    {
    case WM_PAINT:
        {
        

            HBITMAP hbitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL),"bitmap.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
    
            
    
            HDC hdc = GetDC(hWnd);
            HDC image_dc = CreateCompatibleDC(hdc);    


            
            SelectObject(image_dc,hbitmap);

            
            rectangle (our window).
            BitBlt(hdc,50,50,432,424,image_dc,0,0,SRCCOPY);
            

            DeleteObject(hbitmap);  

            
            ReleaseDC(hWnd, hdc);
            
            DeleteDC(image_dc);
    
        }break;            
  
    case WM_DESTROY:
  
        PostQuitMessage(WM_QUIT);
        break;
    default:
        
         return DefWindowProc(hWnd, Msg, wParam, lParam);
    }
    
}



Sorry if this is in the wrong form.
User is offlineProfile CardPM
+Quote Post

lockdown
RE: Very Quick Question
16 Dec, 2007 - 05:15 PM
Post #2

D.I.C Regular
Group Icon

Joined: 29 Sep, 2007
Posts: 376



Thanked: 1 times
Expert In: PC, Support

My Contributions
Your question is a little confusing. Are you asking how someone would plan out and create a program?

When creating a application that is large I will normally take out a piece of paper and draw it out. This is also called a flow chart but everyone has their own way of creating it and how it looks. I then write everything out that I need to declare and what its purpose is. Then I move into my code and build it function by function testing each one as I go. Everyone has their own way of planing and creating a program so this is just mine. I am no expert in C++ so other people that program for a living might have some other ways of doing it.

For the lines of code once you get programming down you know most of them. But from what I have heard people still keeps books around as refrenece because their is a lot to programing.

This post has been edited by lockdown: 16 Dec, 2007 - 05:19 PM
User is offlineProfile CardPM
+Quote Post

Clearman
RE: Very Quick Question
16 Dec, 2007 - 05:27 PM
Post #3

New D.I.C Head
*

Joined: 13 Dec, 2007
Posts: 48


My Contributions
"Are you asking how someone would plan out and create a program?"

In short yes i would like to know how every one dose theres.
i was hopeing you would say something like that and not you just make it up as you go along.I will try using a flow chart next time and some pseudo code .

Thanks for the help.
Any one else know of other ways?

This post has been edited by Clearman: 16 Dec, 2007 - 05:32 PM
User is offlineProfile CardPM
+Quote Post

lockdown
RE: Very Quick Question
16 Dec, 2007 - 05:32 PM
Post #4

D.I.C Regular
Group Icon

Joined: 29 Sep, 2007
Posts: 376



Thanked: 1 times
Expert In: PC, Support

My Contributions
Yeah I have a couple friends that say they just make it up as they go. That said some people can work things out like that in their head with no problems.

Working with flow charts and pseudo code is one of the proven methods to planing. How everyone dose theirs is different but that is one of the first things I learned this semester with C++.
User is offlineProfile CardPM
+Quote Post

Clearman
RE: Very Quick Question
16 Dec, 2007 - 05:41 PM
Post #5

New D.I.C Head
*

Joined: 13 Dec, 2007
Posts: 48


My Contributions
QUOTE(lockdown @ 16 Dec, 2007 - 06:32 PM) *

Working with flow charts and pseudo code is one of the proven methods to planing. How everyone dose theirs is different but that is one of the first things I learned this semester with C++.

I just finish my first semester i just got why they were teaching us data flow diagrams .And there is no way in hell that people can "make it up as they go" they must have been working with c++ for a long time to do that.
Are you in third year or first.
User is offlineProfile CardPM
+Quote Post

lockdown
RE: Very Quick Question
16 Dec, 2007 - 05:54 PM
Post #6

D.I.C Regular
Group Icon

Joined: 29 Sep, 2007
Posts: 376



Thanked: 1 times
Expert In: PC, Support

My Contributions
This is my first semester of college and I just finished my Intro to C++ course with a A smile.gif . I am taking the next course witch is object ori. next semester. But I have my own way of drawing things out similar to a flow chart but I skip the squedo code. I just write out the code as in C++.
User is offlineProfile CardPM
+Quote Post

Clearman
RE: Very Quick Question
16 Dec, 2007 - 06:11 PM
Post #7

New D.I.C Head
*

Joined: 13 Dec, 2007
Posts: 48


My Contributions
lol we have to do java and i got an A.I am the only one who got over a e smile.gif.already 15 out of 23 people dropped out of the class you should see it biggrin.gif.
Right i am off its 2am over here.
btw squedo code is the worst thing made by man i had to do 12 programs with 50-80 lines of code in it crazy.gif .
Thanks again and gl in your coarse icon_up.gif .

This post has been edited by Clearman: 16 Dec, 2007 - 06:11 PM
User is offlineProfile CardPM
+Quote Post

Bench
RE: Very Quick Question
16 Dec, 2007 - 06:28 PM
Post #8

D.I.C Addict
Group Icon

Joined: 20 Aug, 2007
Posts: 617



Thanked: 14 times
Dream Kudos: 150
Expert In: C/C++

My Contributions
Certainly anything bigger than a trivial problem needs some thought, although the purpose of design and prototyping is for the developer to gain a firm understanding of the problem he/she is trying to solve.

Its sometimes said that you only truly understand a problem once you have the solution in your hands - and that's not always too far off from the truth.
You can document all the design and theory that you like, though, until you attempt a prototype or test program, you can never be sure whether there are elements which neither you nor your colleagues had thought of.
Equally, you may sit down with barely a penstroke to paper, and attempt to solve the problem as you see it - This inevitably results in the developer producing the solution to the wrong problem when he/she hasn't really understood it.

Truth is that development is an iterative process - For anything but the most trivial of programs, you will go through several different designs and prototypes before you see the light at the end of the tunnel. Its not entirely unheard of to have an almost-working solution before the formal design document emerges which accurately describes what the application is intended to do.

Its something of a catch-22 situation - You need to have a solution in your hands in order to create the solution; but its one that every software developer faces on a regular basis - and there's no easy answer, in general, the "best" way to develop software is whatever works for the individual or team who are looking for the solution.


By the way, its a little disheartening to hear that so many of your university classmates have been put off by the whole process (And understandably so). Software design is a difficult thing to do, letalone teach; and there's no way that any tutor or course can really teach problem solving to you - its a key skill that only a student can learn him/herself. I expect the university are just trying to teach various techniques, and maybe have taken one or two of them a little too far.

(Nitpick - its actually spelled pseudo-code)
User is offlineProfile CardPM
+Quote Post

baavgai
RE: Very Quick Question
16 Dec, 2007 - 06:49 PM
Post #9

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 2,019



Thanked: 105 times
Dream Kudos: 475
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua

My Contributions
Short answer, no one seriously does it this way. Most windows programs start out with some Microsoft tool that generates this or hides it behind some C++ classes. I haven't seen this kind of code in a very long time.

That said, a guy named Charles Petzold wrote the definitive tome for making windows programs with simple C, the Win 32 API, little more tools than a free command line compiler and notepad. You can check out his books here: http://www.charlespetzold.com/books.html

Of special note is the code offered for now out of print "Programming Windows, 4th edition" ( Windows 95 ). That code should have the hello world prog and a few other basic examples to help you walk this path.

Good luck.

User is offlineProfile CardPM
+Quote Post

Clearman
RE: Very Quick Question
16 Dec, 2007 - 07:46 PM
Post #10

New D.I.C Head
*

Joined: 13 Dec, 2007
Posts: 48


My Contributions
QUOTE(Bench @ 16 Dec, 2007 - 07:28 PM) *


By the way, its a little disheartening to hear that so many of your university classmates have been put off by the whole process (And understandably so). Software design is a difficult thing to do, letalone teach; and there's no way that any tutor or course can really teach problem solving to you - its a key skill that only a student can learn him/herself. I expect the university are just trying to teach various techniques, and maybe have taken one or two of them a little too far.



I have to disagree with you assumption that the people in my class had any problems with problem solving the drop outs were mainly because of 3 things:
1)They had little to no interest in the computing area.
2)7 of them had a hard time with basic english.
3)There is a pub next to our collage.

There are 4-8 people who are good at programming and all of us tried to help them with java but when a person says to you after 3 months of lectures and you helping them with websites given to them and you hear "what is a for loop" you just give up.I wouldn't be disheartened they just didn't care at all.

QUOTE(Be @ 16 Dec, 2007 - 07:24 PM) *

Short answer, no one seriously does it this way. Most windows programs start out with some Microsoft tool that generates this or hides it behind some C++ classes. I haven't seen this kind of code in a very long time.

My great and powerful teacher once said when he was making us sort an array "manually" he said "some programmers just use the .sort function but you are working to be the ninja coders you will be the best"(i.m not kidding).
I will look into 3ed party programs though but still its good to know if you need to make a 3ed party program.
Thanks for the help and the links i will enjoy them.

This post has been edited by Clearman: 16 Dec, 2007 - 07:49 PM
User is offlineProfile CardPM
+Quote Post

skyhawk133
RE: Very Quick Question
16 Dec, 2007 - 08:45 PM
Post #11

Head DIC Head
Group Icon

Joined: 17 Mar, 2001
Posts: 14,931



Thanked: 47 times
Dream Kudos: 1650
Expert In: Web Development

My Contributions
QUOTE
3)There is a pub next to our collage.


I like this reason smile.gif
User is offlineProfile CardPM
+Quote Post

nirvanarupali
RE: Very Quick Question
16 Dec, 2007 - 09:22 PM
Post #12

D.I.C Foot
Group Icon

Joined: 1 Aug, 2007
Posts: 983



Thanked: 2 times
Dream Kudos: 375
My Contributions
QUOTE
3)There is a pub next to our collage.

huh?

Cris was always in the pub, but didn't experience have a plunk on his grades. LOL.
User is offlineProfile CardPM
+Quote Post

2 Pages V  1 2 >
Reply to this topicStart new topic
Time is now: 12/1/08 11:16PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month