a point in the right direction

Discussion in 'Programmer's Corner' started by Chalma, Nov 7, 2013.

  1. Chalma

    Thread Starter Member

    May 19, 2013
    54
    2
    I do not do UI or GUI programming and I was approached with a task. They want me to do it in VB (which is easy but my bosses are taking their sweet time ordering me a copy).....so I want to get a head start and do it in C++. I'm doing this in C++ because I can already predict when I finally get my VB my bosses will want this done in one or two days (happens every time). What I want to do is have a main window then what I plan on doing is having a frame (I call it a frame but basically it'll be a nice little outlined box) and in this box I'll have info, lets say Voltage:,Amperage,RPM:,deltas and maybe a graphic associated with the said box that tells you if it's connected, and I plan on getting data from 25 units (obviously I know that this structred type will be a frame,framename,frame location,volt,amp,rpm,delta,graphicstatepic and I'll just be repeatedly doint his in an array). I just have no idea how to make this array type in c++ windows GUI.I already know I'll be making a user defined type/structure, whatever term you want to use. The problem I'm having is I do not know GUI programming and evidently frame means something else in GUI programming. anyone have a link or can give me the jist of what I need to do? I can do everything else but whenever I put in frame c++ etc. I get something I do not want done. Thanks in advance
     
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    If you intend on using C++, look up the STL containers-namely 'vector'.

    What you are referring to as a frame is typically called a panel.

    Why not use Visual Studio Express to start in the language you are expected to code in? C++ GUI work is typically a tedious task...
     
  3. Chalma

    Thread Starter Member

    May 19, 2013
    54
    2
    to reiderate because I evidently do not know how to write this is what I'd like
    forgive my ascii art as I'm an eqally bad drawer LOL

    ====================================-@X=
    = --1--- ---2-- ---3-- ---4-- =
    = | V | | V ||V | |V | =
    = | A | | A | |A | |A | =
    = | RPM| | RPM| |RPM | |RPM | =
    = ------ ------ ------ ------ =
    = =
    = =
    = =
    = =
    = =
    ========================================
     
  4. Chalma

    Thread Starter Member

    May 19, 2013
    54
    2
    thanks for the quick reply tshuck, I will look into that VB Express. This is just for my workplace and I do not want to get them or myself in trouble for not doing things koasher. Thanks again now I have something to go by
     
  5. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Really, you'll be looking for generic collections, regardless of whether you are using VB or C++. STL containers work wonders for C++ arrays/collections.

    I believe the Express license allows for evaluational usage, though to what extent I'm not sure.

    I'm not quite sure what I'm looking at with your ASCII art there... are you intending on only 4 items, or can this scaled dynamically? The Listbox may be of use to you, in which case, you could use an observable collection(see Google), and override the ToString method in your custom class to display the information you want.

    There are many, many ways to do this, it's just a matter of what you want to do with this information...
     
  6. vpoko

    Member

    Jan 5, 2012
    258
    47
    All of the Visual Studio express versions allow commercial use. I would strongly recommend that (or C# if your company allows it) instead of C++. The learning curve for C++ Windows programming is much higher and you'll spend most of your time trying connect the plumbing instead of focusing on your application logic. Unless you have a specific need to use C++ (i.e., performance benefits of using unmanaged code) there is no good reason to use it and many good reasons not to.
     
  7. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    I'll second this, C# is my preferred language, however, I should point out C# can operate with unmanaged code(unsafe context)..
     
  8. Chalma

    Thread Starter Member

    May 19, 2013
    54
    2
    *BUMP*


    I am so suprised but my company shelled out some money for Visual C++ 6.0. I know it's old but at least it's something. They didn't want to go the Visual Studio route (namely our computer systems are older and they don't want to update everything....don't ask). I went ahead and made a picture of what I would like done. Keep in mind this is only one item that I want, there would be lets say 30+ of these 'panels' for one window. I tried googling the above info on STL, vectors and panels but I didn't see any examples. I shall try googling a opensource RPG because I can see someone utilizing this for a small game (i.e. there are 4 or 5 people in a group with stats). the picture is attatched as I can't seem to include it into this post. Thanks again. I realize that I can highlight multiple items and copy and paste but it just seems silly to repeat doing this 30+ times
     
    Last edited: Nov 25, 2013
  9. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    A reference for C++ containers can be found here.

    If you want examples for the vector container, click on the link corresponding to what you are trying to do.

    The vector class is a generic container, meaning you can put a custom class object in it and iterate over the vector of your objects - think an array of custom objects without dealing with memory allocation and resizing, among other benefits.

    Are you familiar with object-oriented programming?
     
    Chalma likes this.
  10. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    You may want to utilize the .NET framework for your GUI design - I haven't done much with managed C++ GUI design, but it should be fairly easy with the .NET framework, from what I gleaned...
     
  11. Chalma

    Thread Starter Member

    May 19, 2013
    54
    2
    I will check out the materials you listed, they look good. I'm semi familiar with programming, but not very good with OOP. namely it's been years since I took a real course and on top of that the programming I do do is very small scale items. I learn namely from examples and utilization. An former Engineer at my old job created many headers in c++ so that one could interface with IEEE equipment (oscopes, powersupplies, dmms, pulse generators). I learned so much from that and eventually could replicate that (to a point). Sadly when it comes to new material I'm like a big dumb baby LOL. I will def. check out the material and hopefully can get a going. I took a VB course long ago so hopefully learning this VC will go faster. Thanks again.
     
  12. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    You may need to do some brushing up on OOP before using any of the higher level constructs like the .NET framework or STL containers - they are confusing enough when starting with a firm grasp of OOP.
     
  13. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    I have Visual C++ 6.0 here and it is powerful.
    Even have put an ebook online at my website recently which is not bad for learning.

    I don't know GUI programming

    Well...consult a book for instance my online book.

    You have for instance the MFC framework available, providing various means of control such as pushbutton interface, callback functions, even timers, and images.

    There are other ways but I'd say it can be done with the oldfashion GDI.
    you need a handle for a surface to draw, to create a memory context for the bitmaps, some mechanism to re-draw the bitmaps or even redraw directly.

    then there is GDI+, and .NET as well, which does not make it easier at all. With more modern Visual Studio, you get all sort of exotic technologies to assist you, or you even find suggestions to use C# (managed code).

    For the application described, I don't see a benefit of managed code, but for sure mangaged code has benefits.

    It won't be wrong to read a little through the MSDN, and through a book for instance my online book to make yourself familiar with the plain GDI and MFC and the old-fashioned unmanaged way of programming the Windows GUI.

    Maybe for a larger software, you'd be able to see the benefits yourself at some point.

    Oldfashion compilers are not neccessarily bad for some purposes. The new one's are just better in some cases, easier in the long run, easier for others to reuse can be an important reason.

    Or use the FLTK- if you are able to, on Windows- as it comes with some good tutorial websites (one could almost call it cheating).

    It depends what your manager wants in the end- run some production-critical process, or just monitor something.

    What about remote restarts of the machine? Is there someone, or can it be done easily? Or it is not remote at all, is just used on a laptop.

    Does the software have a web interface (for data transfer)?

    The more exact specifications you have, the better the software in the end.
    I'd guess managers sometimes don't know all the technical aspects, they only know some factors (must have) described in human language.

    Before trying vectors, array lists, templates and References, take a look the VC6 stuff since you have it installed and available (I hope includuing MSDN).

    Think the fact alone the software may run correctly some day does not automatically mean it is good software or safe software. Think of what can go wrong in advance.
     
  14. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    If you've never done GUI work, what are you basing this on?

    If you don't see the benefit, can you truly say you know which is better suited to the application?

    Managed code has many benefits - no memory leaks, for one, but most managed languages (C# included) can use unmanaged code to some degree (C# can run fully as unmanaged code).
     
  15. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    I have copied the line from OP. I am not denying the benefits but there can be some effort to learn. And to re-learn if you already can write unmanaged code.

    I don't know how enough about the project: OP is saying now VC++ is used to gain understanding in advance, but then VB will be used.

    Traditionally BASIC was interpreted means managed, only rarely causing a crash. VB is not of course but you don't play around with pointers like in C++.

    I read some years ago VB makes programmers lazy and the codebase resulting won't be too bright so it is kind of a semiprofessional language- used by managers to script something but not neccessarily to program a new 3D game with DirectX (via COM it is actually possible technically).

    When you don't have a leaks problem after a while testing, you don't need to worry about them, right?

    Programming talent can vary, there can be a 300 megabyte Studio ensemble to organize photos in some kind of albums very slowly and difficult to use, there can be a 10 megabyte tool which does it one-click very fast.

    At least Op is admitting GUI is not yet understood and VC++ 6 is installed + available.

    I have it on my laptop too- it starts up reasonably fast in a few seconds, while the new Visual Studio nearly takes a minute.

    To study some algorithm or try some 3D code, it is just right, no managed code needed.

    I even had the old Microsoft compilers and Borland compilers installed from early 1990s but the CHM files are broken there is no sane way to run a 16bit DLL (real-mode) on Vista so VC++ 6 is the oldest tool which can be used.

    I decompiled the help files some day, but the structural difference is just too much, it is simply not worth it.

    Then some years ago I used .NET (I think it is somehow managed).

    Wikipedia could help like a map for a mess of tangled roads, after reading some articles, I wasn't so confused anymore.

    OP also writes there is existing C++ code from an engineer (kind of don't fix a working machine).

    I tried C# a while ago but compared to C++ I found it more restrictive, especially when I play with pointer arithmetic instead of inventing some kind of mega-class covering all potential uses by future generations and to care about access privileges (think I am superuser on my machine).

    It is maybe the mindset of an user who understands about multitasking on a local machine, but does not really understand why each time licences must be signed, and remote access is happening even without permission.

    OK I do understand, but I am not involved into client/server programming.

    For code you know yourself, C++ might be easier but if it is reused or the team is large, managed code adds more safety, the others can't know all the conditions for memory leaks or privilege violations from weird buffer overruns.

    I don't think I just write a fairytale I have read a lot of various MSDN at least I tried to skip through most of it even if reading the details is too much effort.
     
  16. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    You must have skipped over the portion of MSDN that talks about running C# in unsafe context (their way of saying unmanaged -e.g. pointer arithmetic).

    The time it takes Visual Studio to start up vs. the Visual C++ IDE have very little to do with what language they're written in and more to do with features. Visual Studio is the programming environmnet , which is not in any way necessary to run a program written in C#.

    During my stint as a professional software engineer, we used C++ to interface to hardware and things that required bit-level manipulations and a RTOS, wrapped the C++ classes with Managed C++(C++/CLI), which could be manipulated directly by the C# GUI that was quite fast and responsive. The GUI displayed hardware status, simulation status as well as 3D rendering.

    Does writing managed code make people lazy? I would have to disagree, it frees them to focus on the task they mean to accomplish, instead of tracking down small mistakes that may never be found, even with a proper profiling tool.

    Existing C++ code written as a library need not restrict the GUI developer into a specific language as most languages can book into C++ code. As mentioned before, all that is needed to go from C++ code to C# is a wrapper class - very easy to do.
     
Loading...