Thread: VC++

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Crossfire View Post
    well i made my first gui program in c!!!
    Code:
    #include <windows.h>
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
    {
    MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
    return 0;
    }
    ps now that i know forms are NOT c++ as i thought it was, you can move this to where it needs to go!!!

    thanks!
    Now, this raises eyebrowns.
    Win32 is hardly a good technology to use. I strongly suggest you use a GUI Framework.
    But why are you using C all of a sudden?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Registered User
    Join Date
    Mar 2010
    Posts
    583
    Quote Originally Posted by Crossfire View Post
    ok got it, question i have also, can i make a win32 gui program from just c++ or C? cause i would like that MUCH better then this vc++ crap, and easier for touch screen then console
    I'd also recommend Qt. I haven't used it for years - but my memories of it are that it had a slightly steeper initial learning curve than Windows Forms (have to understand a bit more and have less autogenerated for you). But the more I worked with it the more comfortable I was: whereas with Windows Forms I seem to get more perplexed and confused every time I use them. There's a point when they seem to just stop making much sense. The "it's not C++" fact gets more and more glaring too.

    My views might be coloured by using Windows Forms mostly for hacky prototypes -- so I haven't really taken the time to learn how it's meant to all fit together. I just keep bashing it until it behaves, which C++/CLI makes so fun and not at all frustrating

  3. #18
    Registered User
    Join Date
    Dec 2012
    Posts
    307
    using C because i am stronger in C then C++ at the moment, as i been tutoring C for a while now, and have done very little in c++ in the last 4 years.

    and yeah the windows form app i made, i did just that, "I just keep bashing it until it behaves" lol

    basically i am taking a circuit i made for the parallel port (8 data outs + 2 control outs) and instead of using the parallel port (as everything after win me BLOCKED direct writes to the port unless you install a modified driver, and of course parallel ports are getting scarse, and usb to parallel dont work as expected)

    i replaced the parallel port with the vellman 8055 usb "adapter". using the 8 data outs and 2 analog outs.

    the program/circuit uses a "6 pass write" to send data. send one byte(data), trigger flip flop, send i byte (steering) trigger flipflop, then 1 of 320 relays are on.

    well my program was running in console in c++, but now that i am using a toughbook with the vellman board as the center of the controller, i want to be able to "see" all 320 "lights" and click the light or a button underneith to switch them. vc++ seemed the way to go, untill i discovered forms ISNT C++!!! so in short falling back to C like i said, becuase i know it better!

    is there another route that would be better?? like actually using a C++ GUI, over a C GUI?

    my orig program i was already using functions from the api.
    Code:
    void GetWindowSize()
      {
      CONSOLE_SCREEN_BUFFER_INFO csbi;
      if (GetConsoleScreenBufferInfo(
            GetStdHandle( STD_OUTPUT_HANDLE ),
            &csbi
            ))
        {
        lines   = csbi.srWindow.Bottom -csbi.srWindow.Top  +1;
        columns = csbi.srWindow.Right  -csbi.srWindow.Left +1;
        }
      else lines = columns = 0;
      }
    void SetWindowSize(int lines,int columns )
      {
      CONSOLE_SCREEN_BUFFER_INFO csbi;
      if (GetConsoleScreenBufferInfo(
            GetStdHandle( STD_OUTPUT_HANDLE ),
            &csbi
            ))
        {
        // Make sure the new size isn't too big
        if (lines   > csbi.dwSize.Y) lines   = csbi.dwSize.Y;
        if (columns > csbi.dwSize.X) columns = csbi.dwSize.X;
        // Adjust window origin if necessary
        if ((csbi.srWindow.Top  +lines)   > csbi.dwSize.Y) csbi.srWindow.Top  = csbi.dwSize.Y -lines   -1;
        if ((csbi.srWindow.Left +columns) > csbi.dwSize.Y) csbi.srWindow.Left = csbi.dwSize.X -columns -1;
        // Calculate new size
        csbi.srWindow.Bottom = csbi.srWindow.Top  +lines   -1;
        csbi.srWindow.Right  = csbi.srWindow.Left +columns -1;
        SetConsoleWindowInfo(
          GetStdHandle( STD_OUTPUT_HANDLE ),
          true,
          &csbi.srWindow
          );
        }
      } 
     
     
    
    void GetLocation()
    {
        HANDLE hStdout = GetStdHandle( STD_OUTPUT_HANDLE );
        CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo = { 0 };
        GetConsoleScreenBufferInfo( hStdout, &ScreenBufferInfo );
        X=ScreenBufferInfo.dwCursorPosition.X;
        Y=ScreenBufferInfo.dwCursorPosition.Y;
    }
    void GotoXY( short x, short y ) 
    { 
        HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE) ; 
        COORD position = { x, y } ; 
         
        SetConsoleCursorPosition( hStdout, position ) ; 
    }

  4. #19
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    I find it kind of heartbreaking that Elysia caused you to second guess yourself. It is true that you're using CLI, but when Elysia says it "isn't C++" he means it isn't standard C++. Sad fact is that no GUI framework is standard. So you have to make a choice anyway and you might as well go with what works where you want the program to run, and what you're comfortable with doing.

    The good part of a C++ GUI framework is the high probability that it is designed with OOP principles in mind. It may just be easier to work with, it depends on the person.

  5. #20
    Registered User
    Join Date
    Dec 2012
    Posts
    307
    well i would like to continue to use C++ (or my working forms), as that means i dont have to port my programming over to something else!!!

    what IDE/Compiler would you recommend for gui programming? C/C++ hopefully

  6. #21
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    There is nothing wrong with Visual Studio. Neither is there anything wrong with using CLI, as long as you know it's basically a form of vendor lock in. Meaning that you are going to have to rewrite substantial portions of your GUI to get it to run on, say, linux.

  7. #22
    Registered User
    Join Date
    Dec 2012
    Posts
    307
    yeah figured that, looking on youtube for C++ GUI Programming, ended up with ALOT of QT, so i guess i am going to use that! lol

    anyway time to go SNOWBLOW AGAIN!!!!

    ill let you know when i get a program running! I thank you all for the help, and advice. I started on BASIC, and DOS Batch files (which i STILL use today)

    which funny thing about my batch files.

    Back in 2003 while training units for iraq at fort campbell, i also was the network guy. I was asked to goto all 7 buildings i controlled, and get the IP`s Macs, computer names, and Users for everything!!! Well the programs i used to use for network polling were "not approved by DoD" so i thought for a minute, windows is an approved DoD OS, so the build in "dos box" was approved. So i wrote a batch to first ping all my ranges, 1 packet, just to see if it was there, then filtered what was there from what wasnt there, then did an NBTSTAT (netbios lookup) to get the name and mac from the pinged list, then did a directory list from the documents and setting folder to get the users. Well in 2 hours, did my two weeks worth of work, minus the very few systems that were off for the night. And have continued to use that batch ever since for my DoD networks!

    ANYWAY out to snowblow, Thank you again

  8. #23
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It seems I may have confused you.
    I meant to imply that Windows Forms isn't standard C++. Visual Studio is a collection of multiple technologies in one, including C++/CLI and standard C++. So yes, you can use standard C++ with Visual Studio. Although, if you plan on using Qt, you may be better off with their Qt Creator. If using Visual Studio, you would have to do a Console application or Win32 application (not Windows Forms).

    As for C vs C++, I'll be blunt with you.
    C is meant for small embedded systems where resources are scarce and where it just isn't worth investing in big, complex compilers. It wasn't--and still isn't--meant to be used on big platforms such as PC, and it sure as heck is not a RAD tool.
    Using C for PCs means that you will you write code that is pretty unreadable is most cases, difficult to maintain, extremely complex, full of bugs and full of security holes. It doesn't matter if you are an experienced programmer or not. Take a look at your code and tell me with 100% confidentially that there are no security issues or bugs. You just will not be able to.
    Languages such as C++ greatly simplifies this complexity and cuts down on security issues and bugs. Therefore, if you at a privilege to use it, then you should.
    I can't tell you what to do, of course, but this is my opinion based upon facts I know and a little bias. You should make your own decision, though.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #24
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    I still subscribe to "code wants to be broken". I break everything routinely regardless of how "safe and secure" it is supposed to be. Debugging is 90% of programming.

  10. #25
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    A good habit, that one, and one that should be done regardless of language.
    However, no one (and no tool) catches all bugs and spending time hunting down bugs costs money, time and sanity. So reducing them as much as possible is a worthwhile goal.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed