Talk:VGUI2: Creating a panel

From Valve Developer Community
Revision as of 10:29, 19 December 2013 by Davecb 42 (talk | contribs) (Panel wont disapear)
Jump to: navigation, search

Hopefully somebody will reformat the text. Btw.: There is still no <cpp> tag!

Text reformatted. --AiusEpsi 15:19, 3 Jul 2005 (PDT)

There is a <code> tag. MightyMooquack 15:32, 3 Jul 2005 (PDT)
And a cpp tag is much cooler: It has C++ syntax highlighting. Examples: --Leon Grapenthin 09:35, 6 Jul 2005 (PDT)
Is SourceWiki down? Because I can't access it anymore --Pon
I used <source lang="cpp"> --M3t0r 20:56, 28 January 2010 (UTC)

Has anybody been able to follow this and get it to work? I'm having trouble and getting a error...

MyPanel.cpp(78) : fatal error C1010: unexpected end of file while looking for precompiled header directive

I tried compiling it after the modification to vgui_int.cpp when it says to run the game. Anybody having the same problem or am I just royally screwing up?


you need to #include "cbase.h" Ts2do


This is how I solved the previous problem:

fatal error C1010: unexpected end of file while looking for precompiled header directive

  1. name your file CMyPanel.cpp not a MyPanel.cpp
  2. add following headers:

#include "cbase.h"
#include "IMyPanel.h"
using namespace vgui;
#include <vgui/IVGui.h>
#include <vgui_controls/Frame.h>

- comment following virtual functions (there is no implementation??):

// virtual void OnTick();
// virtual void OnCommand(const char* pcCommand);
Warning: Commenting out 'virtual void OnTick(); will prevent you from making a console command for the panel. --Brad Newsom 18:45, 3 Jan 2009 (PST)


Why IMyPanel.h? Why not just MyPanel.h? Wouldn't it be less confusing if we took out the random insignificant things that make people needlessly wonder "why"? Isn't it best to keep things simple and straight forward? Especialy in tutorials? --Gijimbo 09:02, 1 June 2007 (MDT)

Ok so I'm guessing it's because they were following the "IClientPanel.h" and other "Iblahblah.h" naming conventions. But I still have the same question: why? --Gijimbo 09:20, 1 June 2007 (MDT)

Ok, what's the deal with IMyPanel.h in general, does it just provide a supporting class? Do all panels need an I(nterface)? --TheDistur 21:53, 18 Aug 2007 (PDT)

Basically, it's an include that gives the other source files access to the panel you've created. That's what the extern part is doing - giving any code that #include's the file access to the panel. --Daedalus 02:28, 19 Aug 2007 (PDT)
It just exposes the create(parent) and destroy() functions eh? If I have any more questions can I just shoot an email to the address on your user page? I don't want to talk about what might be obvious to most of you coders forever on the Talk page. --TheDistur 12:50, 19 Aug 2007 (PDT)
Correct. Basically, for a panel to be able to be used, it must be created (mypanel->Create(gameParent);) and to stop memory leaks, destroyed when no longer used.
As to posting further questions, I'd prefer if you asked the questions here, because other people might have exactly the same questions as yourself, and the answers would help them too. --Daedalus 05:32, 20 Aug 2007 (PDT)

Calling the panel

Ok so after following the different bits and pieces of corrections and helps that you guys have offered, I finaly got it to compile. Alas, the game menu was no different and "MyPanel" was nowhere to be found. I have the feeling that the "calling the panel" section is what needs attention; serious attention. If someone who has gotten the tut to work would post their whole modified working vgui_int.cpp file, I wouldn't mind revising the "calling the panel" section to make it more understandable/workable. --Gijimbo 09:08, 1 June 2007 (MDT)

I got the panel to show up but when increase the screen resolution the title of the panel becomes huge. When I open the panel editor it's title and numerous other text areas are huge as well. Any suggestions? I'm guessing it's in one of the res files used. --Gijimbo 10:14, 1 June 2007 (MDT)

Adding mypanel->Create(gameParent);

(This is Inside of Calling the Panel)

Where is this added? It just says "Add it after you include" (which never tells you what to include, I'm assuming were including IMyPanel.h)

Can anyone point me to what line or section it should be added into?


Menu Call Is not working

I followed this guide and added the code to make it called from a main menu option, but when I click on the option nothing happens, I just get the click sound. Is the coding for Orange Box different somehow for menu calls?


I got it, keep forgetting my bins copy to a different folder then my mod lol. Moved em over, added a few res files and now it works.

--Laughing Man

Calling Panel In game.

I have looked around and I can not seem to figure out where to put the code for showing the panel in game. Any help with this would be very helpful.


My panel won't show up in Debug mode

So...i created the panel, had a resource file for it and all that but, when i run debug mode, i get the console, bring up the editor (Ctrl+Shift+alt+B) list the panel hierarchy and...nothing (i get the hierarchy but my panel doesn't show up anywhere in there). Does anyone have any idea why that might be happening? Sorry for the novice question, i am new to Source SDK.

error LNK2001: unresolved external symbol

.. have some errors on Visual Studio 2010:

Error 1 error LNK2001: unresolved external symbol "protected: virtual void __thiscall CMyPanel::OnCommand(char const *)" ([email protected]@@[email protected]) C:\Program Files\....\client\MyPanel.obj Client Episodic

Error 2 error LNK2001: unresolved external symbol "protected: virtual void __thiscall CMyPanel::OnTick(void)" ([email protected]@@MAEXXZ) C:\Program Files\....\client\MyPanel.obj Client Episodic

Error 3 error LNK2001: unresolved external symbol "class IMyPanel * mypanel" ([email protected]@[email protected]@A) C:\Program Files\....\client\vgui_int.obj Client Episodic

Error 4 error LNK1120: 3 unresolved externals C:\Program Files\....\Release_episodic\Client.dll 1 1 Client Episodic

I add "kernel32.lib;user32.lib;" in Additional Dependencies (Linker -> Input), but it's not help.

Ranger [1]

Error is confirmed on Visual C++ Express 2008 too.

But I only have the two protected functions as error.

HL2MP Code, Source 2007 Engine. These are the only errors or warning I have in my code.

BuyPanel.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CBuyPanel::OnCommand(char const *)" ([email protected]@@[email protected])

BuyPanel.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CBuyPanel::OnTick(void)" ([email protected]@@UAEXXZ)

Jelemonde [2]

Quick Fix

This error is because you have told the compiler that you are going to override these functions (OnTick and OnCommand) but you have not provided any definitions. The linker can't find them because you haven't written them. Put a pair of brackets '{}' after the definition, or define the functions at the bottom of your panel cpp page. as in:


#include "cbase.h"

class CMyPanel : public vgui::Frame
    // VGUI overrides
    virtual void OnTick();
    virtual void OnCommand(const char* pcCommand);

void CMyPanel::OnTick()

void CMyPanel::OnCommand(const char* pcCommand)

Chezz 20:55, 12 November 2010 (UTC)

Thank! But I still get the "error LNK2001: unresolved external symbol "class IMyPanel * mypanel" ([email protected]@[email protected]@A) C:\Program Files\....\client\vgui_int.obj" error, Can anyone else help?

OKKWAMOS 02:57 02 April 2012 (GMT)

Panel wont disapear

I'm pretty sure all the codes in, the panel apears in game but if i assign a button with the command turnoff it wont disapear when i press it

.res file nmes

In December 2013, the resource file had to have an all-lower-case name to get the VGUI Build Mode Editor use it. If not, the editor would create an all-lower-case.res file and put its changes in that. --dave