Importing a GUI

Discussion in 'Programmer's Corner' started by Eric007, Sep 2, 2014.

  1. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,041
    33
    Hi everybody,

    I would like to know how to import a GUI from a project to another in Visual Studio?

    Say you have developed a Windows Form Application in VB.net and you want to do the same thing but in C++ and you don't want to re-design the UI all over again.

    Thanks in advance!
     
  2. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,377
    494
    Are you sure it is even possible?
     
  3. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,041
    33
    Lol I hope so! It should
     
  4. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,377
    494
    "It should" What makes you say that?

    They are two different languages. VB.NET relies on .net libraries/library. C++ does not. Do you have C++ libraries that provide functionality similar to .net?
     
  5. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,377
    494
  6. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,041
    33
  7. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,377
    494
    Normally GUI is handled by the API. I think the whole point of API was to let people do creative stuff and not bother them with writting GUI every time.
     
  8. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,041
    33
    LOL...This doesn't answer any of the problem posed and you still missing my point!

    Thanks anyway!
     
  9. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,672
    2,708
    I know *nothing* about VB. And it's been at least a dozen years since I wrote a Windows app based on their C++ library.

    But, I've noticed lately that lots of development suites seem to compile the GUI into an XML document, which is later imported into the app through a library call. I know Android works this way.

    I do not know if VS uses XML to package the GUI, or, if it does, if the VB XML is similar to C++ XML, but you may want to look in this direction.
     
    Eric007 likes this.
  10. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,041
    33
    At least someone who understands what I am trying to do... I am required to develop Form application in C++ and as I am better in VB.Net, I am quickly implementing it in VB to see how the system works basically if the design algorithm works and testing the system functionality... I will try to code it in C++ BUT re-designing the UI is a pain...

    I will look into your suggestion...

    Thanks!
     
  11. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,041
    33
    Stupid question!

    How would you do this?

    I want to start from 0 then increment it by 1 and the maximum value is 7, ie

    0+1=1
    1+1=2
    2+1=3
    ...
    6+1=7
    7+1=0
    0+1=1
    ...

    like the addition in a 8-bit register: 255+1=0.

    what's the algorithm?

    i=0;
    i+=1

    bah bah...

    I am actually exhausted right now.. any help on this little math? and Sorry for not posing the question properly but I know you got me... lol
     
  12. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,672
    2,708
    i=(i+1) & 7

    Look at it in binary and it'll become obvious.
     
  13. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,041
    33
    Sorry I didn't get that! which operator is '&'?
     
  14. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,672
    2,708
    Seriously? You are pulling my leg.

    If not, I leave it as an exercise for you to figure out.
     
  15. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,672
    2,708
    Note that the & operator will only do modulo arithmetic for powers of 2. If this is part of your c++ app, you may want to use the actual modulo (%) operator instead. This will work with any number in the case your requirements change:

    i = (i+1) % 8

    Remember that modulo returns the remainder of the division of the two arguments.

    EDIT: '&' is far less computational intensive than '%', but also not nearly as flexible.
     
  16. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,041
    33
    Sorry sorry it is 3am here... I can't think straight nomore... I know the '&' operator... lol

    I think it's time for me to sleep... or else I'll sound stupid here...
     
  17. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,644
    759
    If I followed this properly, the OP derailed his own thread. Good!

    Enjoy!!:p
     
    Eric007 likes this.
  18. vpoko

    Member

    Jan 5, 2012
    258
    47
    OP, you are trying to convert code, you just don't realize it. You're most likely using Windows Forms as your GUI API. Windows Forms has a graphical designer in Visual Studio that lets you drag components visually to lay them out. Behind the scenes, though, is a code-behind file (usually with a .designer extension) that contains statements in whichever language you're coding in, that create your components and lays them out. Dragging components causes Visual Studio to change the statements in that file. In order to import your GUI layout, you need to convert the .designer file's statements into your new language. If you were going between VB.NET and C#, this would be trivial, but with C++ I'm not so sure (I haven't done any C++ Windows development).
     
  19. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,041
    33
    C++ is such a pain for Windows Form application. Lots problem with managed and unmanaged classes, standard and System strings conversion, bah bah bah... I would say VB.net and C# are best for Windows Form Applications,

    anyway I killed it in C++ too ...:):p
     
  20. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,041
    33
    Very obvious! Lesson learnt: it is not too good to work till very late coz the obvious things may become like a *multiple unknowns* equation!
    i = (i+1) % 8 works fine too. Btw i'm done with this thing so I was just saying...
     
    Last edited: Sep 28, 2014
Loading...