none
Display windows in Visual Studio RRS feed

  • Question

  • I see nothing that I can click on to display the various windows.

    I have some code to paste to try out and the code windows already has a lot of code. where does mine go?

    I don't know how to get the code window to appear.

    Wednesday, August 21, 2019 12:18 AM

All replies

  • Hi WVPhysicist,

    Welcome to the MSDN forum.

    How did you create your project in visual studio? What is the type of your project? First, you should create a project and then click the file like .cs file in Solution Explorer and then you can put your code in the editor.

    Most display windows are in the Menu "View", you can find them in it. 

    If the current project already have lots of code, you can add new item by right-click on the project-->Add-->New Item-->select a file like cs.So you can paste them on this page.

    If l misunderstand your issue, please feel free to let us know. 

    BTW, please share some screenshots of your issue and detailed information so that we can troubleshoot your issue as soon as possible.

    Best Regards,

    Perry 



    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, August 21, 2019 7:35 AM
  • I forgot to identify the program I am running-Visual Study 2019 Community.  A whole bunch of things were installed with it for making windows forms and to play with C#.  I am not part of a coding organization - just a hobby.  I would like to make a space flight simulator sort of like the solar system simulators commonly found on the web, one day, but for now the rush is to help a friend make business forms that supply their own instructions.

    I have two screens and the other was off.  That is where the missing windows were hiding.

    So I found the Solution Explorer window and at the bottom was the source file.  So I clicked on it and it is already a long file with, who knows what the stuff means, in it.

    I tried to add new item, like you said, and it refused because the file already exists.

    That doesn't make sense to me.  It should need my file that I copied from some web site.  I named it Csharp.cpp but it is just text to me and I forgot what it is supposed to do.  I don't understand even one line.
    That is the file I want to import and put the code in the source file.

    I don't know where in the source file it should be added.

    Thanks for having much patience. The Csharp file follows:

    using System;

    using System.Windows.Forms;

    using System.Diagnostics;



    namespace WindowsFormsApplication1

    {

        public partial class Form1 : Form

        {

            public Form1()

            {

                InitializeComponent();

            }



            private void button1_Click(object sender, EventArgs e)

            {

                Process[] process = Process.GetProcesses();



                foreach (Process prs in process)

                {

                    listBox1.Items.Add(prs.ProcessName + "         (" + prs.PrivateMemorySize64.ToString()+ ")");

                }

            }

        }

    }


    • Edited by WVPhysicist Wednesday, August 21, 2019 3:28 PM
    Wednesday, August 21, 2019 3:14 PM
  • Hi WVPhysicist,

    Thanks for your feedback.

    What is your original project type like c++ or c#? 

    According to the codes you provided, they are c# codes which can only be combined with c# projects.

    ## If the type of your project is c#, please follow these steps:

    First, right click on your project and select Add-->New item-->Windows Form(remember to rename its name to Csharp.cs)-->then click Add

    

    >>For duplicate name issues we recommend that you rename your project to Csharp.cs.

    Second, you should add some UI controls like Button and ListBox on your new form.

    Third, to add back-end code, you can right-click the view code in your current Form or press F7 so that you can add the second parts of code in your file.

    ## If the type of your original project is c++, then you need to modify the c++ format of your codes.

    Any feedback will be expected.

    Best Regards,

    Perry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Thursday, August 22, 2019 8:00 AM
  • The name of my project is codetest.sin.
    The name of the source file is CodeTest.cpp.
    I made up the name codetest. I don't know where the .cpp came from.
    Here is the listing.  The software made it all up.  I have no idea what it does or where to put my code in it.  This is an experiment.

    // CodeTest.cpp : Defines the entry point for the application.
    //

    #include "framework.h"
    #include "CodeTest.h"

    #define MAX_LOADSTRING 100

    // Global Variables:
    HINSTANCE hInst;                                // current instance
    WCHAR szTitle[MAX_LOADSTRING];                  // The title bar text
    WCHAR szWindowClass[MAX_LOADSTRING];            // the main window class name

    // Forward declarations of functions included in this code module:
    ATOM                MyRegisterClass(HINSTANCE hInstance);
    BOOL                InitInstance(HINSTANCE, int);
    LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
    INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);

    int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                         _In_opt_ HINSTANCE hPrevInstance,
                         _In_ LPWSTR    lpCmdLine,
                         _In_ int       nCmdShow)
    {
        UNREFERENCED_PARAMETER(hPrevInstance);
        UNREFERENCED_PARAMETER(lpCmdLine);

        // TODO: Place code here.

        // Initialize global strings
        LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
        LoadStringW(hInstance, IDC_CODETEST, szWindowClass, MAX_LOADSTRING);
        MyRegisterClass(hInstance);

        // Perform application initialization:
        if (!InitInstance (hInstance, nCmdShow))
        {
            return FALSE;
        }

        HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_CODETEST));

        MSG msg;

        // Main message loop:
        while (GetMessage(&msg, nullptr, 0, 0))
        {
            if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
            {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
        }

        return (int) msg.wParam;
    }



    //
    //  FUNCTION: MyRegisterClass()
    //
    //  PURPOSE: Registers the window class.
    //
    ATOM MyRegisterClass(HINSTANCE hInstance)
    {
        WNDCLASSEXW wcex;

        wcex.cbSize = sizeof(WNDCLASSEX);

        wcex.style          = CS_HREDRAW | CS_VREDRAW;
        wcex.lpfnWndProc    = WndProc;
        wcex.cbClsExtra     = 0;
        wcex.cbWndExtra     = 0;
        wcex.hInstance      = hInstance;
        wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_CODETEST));
        wcex.hCursor        = LoadCursor(nullptr, IDC_ARROW);
        wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
        wcex.lpszMenuName   = MAKEINTRESOURCEW(IDC_CODETEST);
        wcex.lpszClassName  = szWindowClass;
        wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

        return RegisterClassExW(&wcex);
    }

    //
    //   FUNCTION: InitInstance(HINSTANCE, int)
    //
    //   PURPOSE: Saves instance handle and creates main window
    //
    //   COMMENTS:
    //
    //        In this function, we save the instance handle in a global variable and
    //        create and display the main program window.
    //
    BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
    {
       hInst = hInstance; // Store instance handle in our global variable

       HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
          CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);

       if (!hWnd)
       {
          return FALSE;
       }

       ShowWindow(hWnd, nCmdShow);
       UpdateWindow(hWnd);

       return TRUE;
    }

    //
    //  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
    //
    //  PURPOSE: Processes messages for the main window.
    //
    //  WM_COMMAND  - process the application menu
    //  WM_PAINT    - Paint the main window
    //  WM_DESTROY  - post a quit message and return
    //
    //
    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        switch (message)
        {
        case WM_COMMAND:
            {
                int wmId = LOWORD(wParam);
                // Parse the menu selections:
                switch (wmId)
                {
                case IDM_ABOUT:
                    DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
                    break;
                case IDM_EXIT:
                    DestroyWindow(hWnd);
                    break;
                default:
                    return DefWindowProc(hWnd, message, wParam, lParam);
                }
            }
            break;
        case WM_PAINT:
            {
                PAINTSTRUCT ps;
                HDC hdc = BeginPaint(hWnd, &ps);
                // TODO: Add any drawing code that uses hdc here...
                EndPaint(hWnd, &ps);
            }
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        return 0;
    }

    // Message handler for about box.
    INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    {
        UNREFERENCED_PARAMETER(lParam);
        switch (message)
        {
        case WM_INITDIALOG:
            return (INT_PTR)TRUE;

        case WM_COMMAND:
            if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
            {
                EndDialog(hDlg, LOWORD(wParam));
                return (INT_PTR)TRUE;
            }
            break;
        }
        return (INT_PTR)FALSE;
    }


    When I created the project I believe I selected windows forms .net framework.
    I wanted C# and chose a description that contained it.

    I don't know where to put my code in the source file.

    I have no idea how to modify the format of my code.

    I don't know how to get the window which you show to the right of the toolbar
    and I don't know which toolbar to use. I played with buttons once before and also a List Box or something for display.

    Here is what my friend wants me to make for him:

    "1. I need a splash screen, a window that will come up, introduce the application, then go away automatically.

    2.  A icon-based menu system that will allow the user to click on an icon to choose the desired item or application.

    3.  Access/ability to access/launch a small program from the main program.

    4.  Ability to open email.

    5.  Ability to create/send email.

    6.  Ability to get a file.

    7.  Ability to send a file.

    The question is the best language to accomplish each task.  They don't all have to be written in the same language. "





    Thursday, August 22, 2019 2:38 PM
  • Hi WVPhysicist,

    Since your project is based on c++,l suggest you can create a c++ windows form project. The solution is also suitable for vs2019. l am sorry to tell you that you can not add the c# file in the solution since your source file is based on c++.

    1. You should right-click on your solution in the solution explorer like codetest.sln to Add a New Project like the picture l deep:

    >>The codetest.sln is a solution which can contains many projects as you want.

    2.follow the link to create such project and then you can add your codes in the windows form like the reply l mentioned above and if you want to call the new project into the source project then you can reference the project by Add reference in the source project .

    Also, please change your codes from c# to c++.

    BTW, our forum is to discuss the use of the VS IDE and editor. If you want the help for development, please redirect your issue to c++ forum for better help.

    Best Regards,

    Perry



    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com







    Friday, August 23, 2019 10:44 AM
  • Since my source file is based on c++ instead of c#, I have made a serious error.  Should I start over? Or is there some way to switch?   I don't know how to do either.

    Also before I make any more mistakes I have to narrow my goal to doing the tasks on the list.  I would be amazed just to do the first three.  I hope they can be done with c#.

    Saturday, August 24, 2019 3:22 AM
  • Hi WVPhysicist,

    l am sorry to tell you that the two languages can not convert to each other by tools. So please rewrite or look for c++ based projects.

    BTW, if you want to develop your projects by using c++, you can redirect your issue to c++ form.

    Thanks for your understanding.

    Best Regards,

    Perry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com



    Monday, August 26, 2019 10:50 AM
  • It looks like I am in over my head, so I best abandon the other guy's project for now. I have no understanding of his hardware or software environment or even language constraints. He says he wants Visual Studio and C# but I have no experience to speak of with either.  I learned C and avoided C++ which my tutor said made C worse.
    I have done most of my programming for myself in Microsoft's Quick Basic found on Dos 6.1.
    I just watched half of the Channel 9, Bob Tabor class on "Visual Basic Fundamentals for Absolute Beginners" and decided few of the commands do things that I need and I see no cammands for doing things that I must have.  Things like cartoons. Then I found and scanned scanned the names of other classes and it would take a long time to get up to speed.
    So I give up on my friend's project for now.  I think I might have a chance with my project. It runs on a Windows 10 PC and all I need to show is a black screen with a circle in the center and some white dots going in circles to represent planets, comets or space ships. Sort of like the Solar System.
    I plan to use keyboard input to make adjustments to the numerical parameters. I need to find the best language and most general set-up so this will work on any browser without any special installation-stand alone code. I have looked at other Solar System models and they mostly use Javascript, as best I can make out. Which I think the Kahn Academy teaches for animations but they don't say. (It looks pretty and easy but I can't make it work on my machine) So I am leaning toward Javascript unless there is something better. Hopefully someone can point me in the right direction.

    Thanks,  Charles in West Virginia
    Monday, August 26, 2019 7:32 PM