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

Hybrid View

  1. #1
    Join Date
    Mar 2014
    Posts
    23

    Could not find type int

    Hello.
    I'm new to C++/CLI programming and i recently encountered a problem.It's propably so basic that I've failed to find it on the web...
    Code:
    int ScreenX,ScreenY;
    
    	void InitializeComponent(void)
    		{
    			ScreenX = Screen::PrimaryScreen->WorkingArea.X;
    			ScreenY = Screen::PrimaryScreen->WorkingArea.Y;
    ...
    Error:
    Message 5 Could not find type 'int'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU. 0

    Thx in advance.
    Last edited by Fides Facit Fortis; March 15th, 2014 at 08:00 AM.

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Could not find type int

    Is the InitialzeComponent() function of which you posted the first lines the one created by the Visual C++ IDE in a form class' header file? The first two lines of the function body look like they've not been created by the IDE. Never ever change (or add or remove) anything inside that function! Failure to observe this rule will severely mess up the Forms Designer and may make all sorts of weird and unpleasant things happen. And at least some versions of the IDE post a clear warning against modifying the function in a comment right before.

    Instead, perform initializations like that in the form class' constructor (or a function of your own that you call from the constructor). Depending on your intentions, another good place for initialization code (typically higher-level than that in the constructor) may be the form's Load event handler.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Mar 2014
    Posts
    23

    Re: Could not find type int

    OK so I've moved my code from InitializeComponent to form's constructor,but that didn't change anything.

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Could not find type int

    This is one of the things that may happen in such a situation,. Better create an entirely new Windows Forms project and start over. If you've already made any significant effort in writing code in your current project, you can copy and paste existing code into the new project.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

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