CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2009
    Posts
    3

    Question concerning the Win32 API, and analysing user input

    I've recently begun learning the basics of the Win32 API - so let me start by making it clear, that I am in no way a professional on this front!

    Basically I've already written a C++ Console app, with the purpose of searching large documents and databases for coordinates of the form: [x-coordinate:y-coordinate]! As the win32 Console doesn't really provide any practical means of copy/pasting large numbers of coordinates into it's command-line, I found it more practical to save these large number of coordinates (we're talking thousands), as external documents and then having the console app search, analyse and catagorise these coordinates according to a set number of parameters! This works great!

    Now I figured I would achieve a more user-friendly program if I in some way could convert this into a win32 app, and remove the need for reading external files in order to analyse these coordinates!

    my goal is to just be able to copy-paste the 100+ lines that contain these coordinates directly into the program-window and have it analyse them! I figured the Win32 API would allow me to do just that - so I started learning Win32 Api programming (whereas my only previous experience lies in Html and C++ programming)! I've gone through a number of tutorials and I believe I now have a grasp of most of the fundamentals of Win32 app creation!

    My Question is; Is it possible to create an Win32 Application with a simply window where the user can insert text, and then press a button to have the application analyse the text?

    If so, I do NOT want example's! I'd love if someone could simply mention which parts of the Win32 API could help me achieve this? Which commands could help me achieve such a state?, and even better if you've got a specific tutorial in mind (although this last one is not a requirement)!


    And let me once again make it clear that I am in no way a professional on this front - in fact I've just recently begun learning the Win32 API!


    I'd like to thank all and any help in advance!

    Happy New Year to you all

    ---> Kristian Dashnaw

  2. #2
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Question concerning the Win32 API, and analysing user input

    My Question is; Is it possible to create an Win32 Application with a simply window where the user can insert text, and then press a button to have the application analyse the text?
    Yes. It is possible. You may either use native Win32 or use MFC for the same.
    Right now, creating a Dialog based MFC application via wizard would definitely help. Select MFC, select Dialog based application and finish. As soon as Visual Studio finishes creating the application, it would show you dialog editor. There in, double click the "OK" button and it would show you the code editor.

    Now, it depends on you how you read the input. From file? Or from user? Are you going to input X and Y coordinates from user? If so, you should use Edit/Text control.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  3. #3
    Join Date
    Jan 2009
    Posts
    3

    Re: Question concerning the Win32 API, and analysing user input

    I've created an MFC dialog-based application as suggested, and it does enlighten me somewhat on this subject

    If anything it's a useful demonstration on the Basics of using the MFC! Although I'll probably be rewriting it from scratch anyways! (for learning purposes, I find that I learn more when I write the entire application myself)

    As for the user-input, my original Win32 Console Application read the coordinates from external Files! However, in this application I'm attempting to change it so that it is actually the user that inputs the coordinates!

    Basically my idea was to allow the user to insert large numbers of Coordinates, such as this:

    "[X:Y] [X1:Y1] [X2:Y2] [X3:Y3]
    [X4:Y4] [X5:Y5] [X6:Y6] [X7:Y7] [X...:Y...]......"

    And then simply have the application analyse these coordinates one by one! The main point, however, is that ALL the coordinates are to be inserted at once! Hence the user will not have to enter each coordinate, one-by-one!

    Anyhow, I'll take a look at the Edit/Text control you mentioned

    Thank you for the help!
    Last edited by Dashnaw; January 2nd, 2009 at 04:22 PM. Reason: Spelling error!

  4. #4
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Question concerning the Win32 API, and analysing user input

    To take "inputs" from user, dialogs are one of the best options.
    You can use class-wizard to get a new class, for a new dialog.
    Or you can start by creating new dialog resource (Ctrl+1).

    I don't use class wizards, so can't explain the process. Better you search for on line help, samples, try yourself out..
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  5. #5
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: Question concerning the Win32 API, and analysing user input

    Quote Originally Posted by Dashnaw View Post
    The main point, however, is that ALL the coordinates are to be inserted at once! Hence the user will not have to enter each coordinate, one-by-one!
    What is the source of your coordinate data? You have mentioned copy/paste, so the data is already in yuor computer? Where? There might e a more direct wy to get to it
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  6. #6
    Join Date
    Jan 2009
    Posts
    3

    Re: Question concerning the Win32 API, and analysing user input

    Basically my idea was to have a text-field area in the application window (much like the "rich edit" dailog controller), where the user may input a large number of coordinates!

    The coordinates are basically part of a larger text! let me attempt to illustrate it:

    I've got the following piece of text:

    02:16 - 2. January 2009, Object at [382:03] 02:18 - 2. January 2009, Object at [385:05] 02:20 - 2. January 2009, Object at [387:04] 02:22 - 2. January 2009, Object at [390:08] 02:24 - 2. January 2009, Object at [395:10] ........etc...

    My idea was to simply allow the user to open the text-file with the raw data - press ctrl+a, followed by ctrl+c, and then simply ctrl+v it into a text-field inside the main application window, where there would be a button called "analyze", that would analyze the text, search for coordinates and catagorise them after a number of parameteres preprogrammed into the main application, and then finally post the results in another (non-editable) text-field also inside the main application window!

    So far I've seen some interesting things with the Microsoft Foundation classes, so right now I'm focusing on getting the basics of these classes down - before proceeding with creating the application! However, I'm all ears, if you've got a more direct and faster method to achieving this, VladimirF

  7. #7
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: Question concerning the Win32 API, and analysing user input

    Quote Originally Posted by Dashnaw View Post
    My idea was to simply allow the user to open the text-file with the raw data - press ctrl+a, followed by ctrl+c, and then simply ctrl+v it into a text-field inside the main application window, where there would be a button called "analyze", that would analyze the text, search for coordinates and catagorise them after a number of parameteres preprogrammed into the main application, and then finally post the results in another (non-editable) text-field also inside the main application window!

    ...However, I'm all ears, if you've got a more direct and faster method to achieving this, VladimirF
    Instead of open+select+copy+paste+analyze, you could simply open that file in your app and parse it right away. What esle user would do with that data?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  8. #8
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Question concerning the Win32 API, and analysing user input

    Quote Originally Posted by Dashnaw View Post
    Basically my idea was to have a text-field area in the application window (much like the "rich edit" dailog controller), where the user may input a large number of coordinates!
    Well, maybe I'm missing something, but I still can't get how Win32 API could help you except getting a window text and placing it to some buffer. Is that your problem??? Because parsing some well structured text (placed in some buffer) is totally different story.
    Best regards,
    Igor

  9. #9
    Join Date
    Nov 2008
    Posts
    39

    Re: Question concerning the Win32 API, and analysing user input

    i think you'll find that copy/pasting the text out of the file is quite overkill. I have never used MFC as i find it to be a waste of time... i prefer to program directly in the API. the windows API provides a simple way to have an 'Open' dialog in which the user can select a file. once you get the file the user selects, you could then just directly open and parse the file from there. here is some MSDN info on Open dialogs:
    http://msdn.microsoft.com/en-us/library/ms646960.aspx

    from the sounds of it, you should just be able to use an Open dialog to get the file name, then open and parse the file directly.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured