CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: MFC question

  1. #1
    Join Date
    May 2015
    Posts
    450

    MFC question

    Hello,

    I wanted to display the output of some algo , on the dialog.
    I tried to use the legacy code to display this, but the window is very small and not resizable: It looks like the WS_MAXIMIZEBOX doesnot have effect.

    Code:
    IDD_TAC_PLANNER_RESULT_DLG DIALOGEX 0, 0, 215, 79
    STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX 
    CAPTION "TAC Result"
    FONT 8, "MS Shell Dlg", 400, 0, 0x1
    BEGIN
        PUSHBUTTON      "Cancel",IDCANCEL,158,58,50,14
    	CONTROL         "",IDC_TAC_SITE_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,4,39,253,264
        DEFPUSHBUTTON   "OK",IDOK,104,58,50,14
    END
    I copied from the following legacy code

    Code:
    IDD_INTFMAT_ANALYSIS_DLG DIALOGEX 0, 0, 642, 321
    STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
    CAPTION "Interference Table Analysis"
    FONT 8, "MS Shell Dlg", 400, 0, 0x1
    BEGIN
        DEFPUSHBUTTON   "Close",IDCANCEL,588,305,50,14
        CONTROL         "",IDC_INTFM_SITE_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,4,39,253,264
        COMBOBOX        IDC_INTFM_FILTER_COMBO,34,6,223,85,CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_SORT | WS_VSCROLL | WS_TABSTOP
        LTEXT           "Filter:",IDC_STATIC,5,8,24,8
        CONTROL         "",IDC_INTFM_INTERF_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,262,7,376,296
        LTEXT           "Find:",IDC_STATIC,6,25,17,8
        EDITTEXT        IDC_INTFM_FIND_EDIT,34,22,174,14,ES_AUTOHSCROLL
        PUSHBUTTON      "Find",IDC_INTF_FIND_BUTTON,217,22,40,14
        CONTROL         "Render on 2D view",IDC_INTFM_RENDER_CHK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,307,129,10
        PUSHBUTTON      "Report",IDC_INTF_REPORT_BUTTON,207,305,50,14
        EDITTEXT        IDC_INTFM_PRECISION_EDIT,422,306,14,13,ES_CENTER | ES_AUTOHSCROLL | ES_NUMBER
        LTEXT           "Interference Display Precision (decimal places)",IDC_INTFM_PREC_STATIC,265,307,153,11
    END
    I donot have any expirience of working with MFC. Please kindly help

    thankyou very much
    pdk

  2. #2
    Join Date
    May 2015
    Posts
    450

    Re: MFC question

    I changed the

    IDD_TAC_PLANNER_RESULT_DLG DIALOGEX 0, 0, 531, 279

    and dialog is bigger now.

    But the cancel button is on left top corner, i wanted it to be somewhere down.

    Also it will be helpful, if somebody can help me withe the list:
    LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT

    Not used it .

    I just used the EDITBOX

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,553

    Re: MFC question

    Are these from a .rc file? Why not use the VS resource editor?

    See https://docs.microsoft.com/en-us/cpp...?view=msvc-160
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++20 Compiler: Microsoft VS2019 (16.11.5)

  4. #4
    Join Date
    May 2015
    Posts
    450

    Re: MFC question

    Thanks a lot, kaud..I tried to use it, but somehow cannot move the cancel box.. may be doing something wrong.
    May be i need to go through basics of MFC, before this.

    I was hoping i can use the existing code as reference to create a similar output dialog, but is getting complicated

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,100

    Re: MFC question

    Quote Originally Posted by pdk5 View Post
    Thanks a lot, kaud..I tried to use it, but somehow cannot move the cancel box.. may be doing something wrong.
    May be i need to go through basics of MFC, before this.
    Yes, you do need to go through the basics of MFC. However, it has nothing to do with using the c++ resource editor, which in most cases is obvios and intuitive.
    Victor Nijegorodov

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,624

    Re: MFC question

    Quote Originally Posted by pdk5 View Post
    Thanks a lot, kaud..I tried to use it, but somehow cannot move the cancel box.. may be doing something wrong.
    May be i need to go through basics of MFC, before this.

    I was hoping i can use the existing code as reference to create a similar output dialog, but is getting complicated
    Your time would be better spend learning to use the resource editor and the wizards.

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,495

    Re: MFC question

    When I first started learning MFC 25 years, I started learning by walking through the MFC scribble tutorial. It didn't necessarily help with what I was immediately doing at the time, but it gave me a fundamental understanding and foundation of MFC that has proven to be invaluable. As I gained experience, I became one of those folks that answered questions on DLs (old equivalent of forums) rather than folks that keep asking questions. Now, my experience wasn't only from doing the scribble tutorial but it definitely gave me a leg up in understanding MFC.

    Hopefully, the scribble tutorial is still available, because it is worth the effort in working through it.

    Another piece of advice, as a 25 year MFC veteran, is too learn MFC as its meant to be used. What I mean is to start a new MFC project using the appropriate new MFC project wizard, use the class wizard to add message handlers and create new dialogs, views and so on, and use the resource editor to edit the resources, rather than trying to hand code all of this stuff.

    Too often I've seen folks try to be smart and attempt to hand code MFC, only to run into trouble when trying to use the class wizard or resource editor later (as a result of thier hand-coded project missing some key MFC infrastructure). MFC has extensive tooling - the best advice I could give is to learn how to use it.

  8. #8
    Join Date
    May 2015
    Posts
    450

    Re: MFC question

    Thankyou very much Arjay, , I'll try to find scribble tutorial you mentioned.
    Also thanks for GCDEF, Victor for the suggestions

    Most of my collegues, try to handedit stuff, may be they are using for decades, which is not applicable for me.

    Im new to MFC.

    Due to Christmas holidays are starting, just before i need to finish this work, helped me , as yesterday, i tried to create a new MFC application on visual studio.

    I was able to create some simple edit box, cobo box, radio buttons, list box etc.

    It is good that i started this way, because, with our lot of legacy code, i was unable to understand the basics..

    I also started to create a simple verion of list_ctrl, i needed for my dialog.

    Basically, i want to display the following from the map.

    Attachment 35928

    I have a map of central site and list of sites that fall under that site
    std::map<int, std::vector<int> >, in this map, first element is the first column, and second column can have multiple sites..

    I was planning to use the list_ctrl to implement this... Any suggestions/advice is very much appreciated.
    Last edited by pdk5; December 21st, 2020 at 10:04 AM.

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