Jump to content
  • Advertisement

Helter Skelter

  • Content Count

  • Joined

  • Last visited

Community Reputation

332 Neutral

About Helter Skelter

  • Rank
  1. Helter Skelter

    strange mfc error

    Quote:Original post by Ultraseamus looks like that may have worked, i took out all of the control variables i had, then remade them and it seems to be running fine now. Just curious was this problem caused by somehting i did worng(if so i would like to know what it was so as too avoid it next time), or is it just some bug with visual studio? As far as I can tell it's a problem with visual studio. In all the times I've encountered this problem the result has been one of two things. Either dev studio crashes or I get a script error when the class wizard is opened. In the pre VS.NET days the IDE required certain AFX tags be placed in comments in order for the class wizard to function properly. With VS.NET this is no longer required as the source files are supposed to be fully parsed. Unfortunately this probably isn't the last time you'll encounter the problem. **EDIT** BTW, this problem tends to pop up when you are using classes derived from the MFC base. IMHO this probably confuses the class wizard if it's unable to locate where that class is declared.
  2. From what you've described it doesn't sound like you should be using a modaless dialog box. The only real reason to use a modaless dialog box is if you want the user to be able to access the parent window (or windows of a thread) while the dialog box is displayed. From what you've described it sounds like you want the drop down to act just like an item on the menubar. If this is the case I suggest adding an owner drawn push button to the toolbar (drawing whatever caption you want and adding a down arrow to signify it being a drop down option) then displaying the listbox control whenever the button is clicked. For the listbox add a handler for WM_FOCUS and simply hide it when the listbox loses focus. Since the listbox will be displayed when you click the button you will be able to adjust it's position either by getting the coordinates of the mouse or the button itself. A good reference for this can be found at http://www.codeguru.com/cpp/controls/buttonctrl/menus/article.php/c7325/ which describes creating a popup menu when a button is clicked. Just replace the call to TRackPopupMenu() with code that adjusts the position and displays the listbox control, handle the WM_FOCUS message, and you're good to go. **EDIT** Verify that the rich edit control is being creating with the correct ID (IDC_RICHEDIT). To do this fire up Spy++, locate the window, and expand the tree to display all the decendents. You should also throw in ASSERT_KINDOF() after each cast to make sure that the window types are correct.
  3. Quote:Original post by uncle_rico I have somewhat of an update, if anyone is interested. My program uses a document template. It's an SDI program, and the main frame just shows one view, which is derived from CFormView. I'm not exactly sure what you are trying to accomplish with this set of code. From the description it sounds like you're trying to create a modaless dialog box (as opposed to calling DoModal() in the dialog class). If this is the case it's a whole different ball of wax and simply calling create() is not going to get you to where you need to be as dialogs are handled a bit differently than normal windows. If you ARE creating a modal dialog the initializtion will need to be done within the OnInitDialog() method of the dialog class.
  4. The most optimal way to accomplish this is to override PreSubclassWindow() in your derived CComboBox class. After calling the base implementation get a handle to the listbox control (using GetComboBoxInfo), subclass it, and call InvalidateRect(listboxHwnd, NULL). This will force the listbox control to be redrawn after the combo box has been bound to your CComboBox derived object. It's important that this be done AFTER calling the base implementation so as to allow all window messages (such as WM_CTLCOLOR) reach the combo box class before the default message handler. Both www.codeguru.com and www.codeproject.com are excellent resources for MFC related issues.
  5. Helter Skelter

    Visual Studio gone haywire

    I've had this happen when dev studio crashes during a compile. Every once in a while this will corrupt the incremental link file (.ilk). Most of the time you can correct this simply by deleting the .ilk and target files (.exe, .dll. lib) and doing a compile. Sometimes you'll have to do a complete rebuild on the project in order to correct it.
  6. Helter Skelter

    strange mfc error

    The crash you are experiencing is generally IME caused by the IDE's inability to parse and add the DDX handlers executed during the instantiation of that particular class which binds windows controls to the various variables such as CStatic and CListCtrl ( see DoDataExchange() ). Unfortunately it's been quite a while since I've encountered this problem but IIRC it had to deal primarily with the placement of certain MFC macros in relation to other macros defined in the application itself. The last time I encountered this problem I removed damn near everything from the header and source files, placed them into a seperate file (not included in the project) and incrementally moved various bits of code back into the main source while binding variables to the controls.
  7. Helter Skelter

    Mapping strings to variables?

    Well it really depends on where the variable is declared and how it is used. Typically you will simply map functions which allow you to retrieve or change the value of the variable. This is usually desirable rather than granting direct access to the variable. One problem you are bound to run into is directly mapping structure/class members for direct access. Sometimes it's more desirable to map the vars for direct access (especially for the countless windows API structs) but becomes tricky. In these cases you need to calculate and store the offset rather than a pointer to the data type. You can do this with a macro similar to the following: #define get_var_offset(type, var) ((int)&(((type*)0)->var)) This returns a zero based offset into the structure for where the variable resides. If you're not using structures simply map the pointer to the variable.
  8. Sometime back someone requested a list of predefined macros for various compilers. At the time I couldn't find the link but someone else had suggested looking at the boost source. I don't know if the original poster is still looking for the info but here's the link: http://predef.sourceforge.net The page contains a list of predefined macros specific to compilers, architectures, operating systems, libraries, and standards (ANSI C and ANSI C++). the list is fairly complete and actively maintained.
  9. Helter Skelter

    virtual keyword

    While it is not necessary in C++ to continue declaring methods as virtual when subclassing it's generally considered good practice to get into the habit of doing so. Newer languages such as C# require that you specify the 'override' keyword on methods that override a virtual method in the base class. In C# an error can be generated for an instance method with the same signature of a virtual method declared in the base class (see ECMA-334). It is generally considered highly desirable to declare your intentions explicitly rather than relying on implicit assumptions (even when tools such as doxygen can make note of the override).
  10. Helter Skelter

    calling conventions

    Calling conventions work as follows: __cdecl pushes parameters on the stack in reverse order (right to left) with the caller responsible for cleaning up the stack. __stdcall pushes parameters on the stack in reverse order (right to left) with the callee responsible for cleaning up the stack. __fastcall pushes parameters on the stack in reverse order (right to left) with the 2 left most parameters passed in registers. Callee is responsible for cleaning up the stack. thiscall (which is not a keyword but an implicit calling method) pushes parameters onto the stack in reverse order (right to left) with the this parameter passed in ECX. Callee is responsible for cleaning up the stack. For class members that accept a variable number of arguments the this pointer is pushed onto the stack instead of being passed in ECX and the call is implicitly impemented as a __cdecl type call. This is necessary since the callee has no explicit or implicit indication of the number or size of the parameters actually passed. Each calling method also has it's own name decoration attributes in order to prevent interpretation of methods using an incorrect calling method. This differs depending on whether the code is compiled as C or C++. More information can be found in the MSDN.
  11. Helter Skelter

    Compiler design

    Quote:Original post by Khaos Let's say I wanted to create a compiler for a little language of my design. Could someone explain the general process? Traditional compilers are broken down into several parts starting with lexical analysis. This takes an input stream (memory buffer, file, etc) and tokenizes the input. In the case of operators that are represented by more than one symbols (say '==' or '!=') a single token is used to represent them. For languages such as C, C++, and Java the lexical parser usually skips over whitespaces, new line characters, and comments rather than returning them as tokens (which makes parsing easier). The next component is the parser which takes the tokenized input and matches it against the grammar of the language. In many cases the parser and lexical tokenizer work in parallel with the lexer returning one token at a time and the parser checking, accepting, rejecting, or skipping tokens in the input stream based on the langauges grammar. A good number of compilers use this step to create an abstract syntax tree. This is a tree of data structures representing the tokenized input in such a way that represents their position in the input stream. Next you might run the abstract syntax tree through an optimizer that would either modify or remove certain nodes in the tree. This might be done to accomplish common subexpression elimination, constant folding, or loop unrolling depending on the type of target (VM or CPU). From here you have several options to decide upon. If you are using an abstract syntax tree you might convert it into intermediate code that represents the operations in a sequential fashion rather than that of the AST. You also might generate assembly code or directly emit a binary object or java like class file. Quote:Should the compiler take my code and turn it into assembly code....Either way, that doesn't seem like the right thing to do. This is a common approach and is by far one of the easier methods and quite acceptable. Compilers that don't use an external assembler to generate .obj or java like .class files generally generally have an internal component that does virtually the same thing. Quote:Also, I don't want to use those compiler design libraries. But anyway, how do the current compilers do it? While you can certainly create all the lexical and grammar parsing parts of the compiler by hand I don't recommend it. Tools such as flex, bison, antlr, etc. are extrmely helpful and make langauge development much easier - especially since you will likely end up duplicating code in hand made parsers. Quote:So, in general, what is the compiler converting my code into. Say for example: x=10; x=x+1 -> What might this be converted into, in general? Depending on the operations performed on x before and after the code given you might end up with something like this: ; unoptimized mov dword ptr [ebp - 4], 10 ; set x = 10 mov eax, dword ptr [ebp - 4] ; get x add eax, 1 ; add 1 mov dword ptr [ebp - 4], eax ; set x ; partial optimization mov dword ptr [ebp - 4], 10 ; set x = 10 inc dword ptr [ebp - 4] ; do x = x + 1 For code generation look into using a burg implementation which, like bison and flex, takes an input file describing the operations to generate code for and automatically creates a code generator. For an example of a compiler containing hand coded lexer and parser along with a burg code generator take a look at LCC.
  12. Helter Skelter

    Warnning dynamic casting

    Quote:Original post by MaulingMonkey smart_idiot: I was under the impression that enabling RTTI had no effect (preformance or otherwise) on casting except actually enabling dynamic_casts sideways/upwards (which not working without RTTI can't be directly compared)? Sane compilers should deduce type from the vtable pointer (and since dynamic_cast only works with polymorphic types - e.g. those types allready having vtables - this will mean no extra per-object overhead, only per-type). The vtables pointed to by polymorphic types (MS compiler) are actually an offset into the types RTTI data structure. The first 4 bytes of the data structure (vtable - 4) point to the RTTI object descriptor. This contains pointers to other information such as the class hierarchy, a pointer to the base classes rtti descriptor, and a pointer to a const instance the std::type_info object. When a dynamic cast is done the performance can be primarily gauged by the distance between the relationship of object being cast and the type it is being cast to. One of the more inefficient calls made during the cast is in FindSITargetTypeInstance() which is internal to the runtime. Depending on the distance one or more calls to strcmp will be made on the contents returned by type_info.raw_name() not to mention the amount of searching done through the heirarchy of both class types involved in the cast.
  13. I am nearing the completion of code for an article I have been considering writing. The topic deals with runtime polymorphic types and enhancing the existing RTTI available in C++ (and specifically the MS C++ compiler). The code originally started out as a way to access all of the RTTI information generated by the compiler for polymorphic types but has grown considerably since its inception. My current intention for the article is to cover the following topics: 1. Documenting the RTTI data structures generated by MSVC including a framework for accessing the data. 2. Generating a catalog of classes, structs, enumerations, and type aliases (typedefs). 3. Using the catalog to provide reflection API's. 4. Provide runtime virtual inheritance. 5. Allow automatic generation of marshaling for interpreted/scripted environments. C# and the Mono implementation of the ECMA-335 runtime are being used for the article examples. Currently the only portion of the effort which is unfinished is the tool for gathering all of the type and RTTI information. The tool pulls all the necessary information from the program database file that is generated by the compiler. This uses the (typically named) vc70.pdb file which is the only complete source of type information before the library/program link is started. Unfortunately the debug helper lib (dbghelp.dll) does not handle this this file properly and the DIA SDK is only available with the Universal MSDN distro. This means the PDB lib needs to be implemented which is the only major delay for starting on the article itself. I am very interested in getting some input from other developers on different features and functionality they would like to see in this library. If I was writing the library just for myself I probably wouldn't care much but since I'm targeting a fairly large audience I figured I would get some opinions on what type of information and features other developers would like. Suggestions? Requests?
  14. Helter Skelter

    DLL exporting warning/issue

    Because the parameters to a template based class used by external applications are unknown at compile time of the DLL it is impractical (and near impossible) to export the template class. This means you need to create a specific type declaration of the template in order for it to be exported: __declspec(dllexport) typedef templateclass<param1, param2> exportedType;
  15. Quote:Original post by pcxmac I have used templates before, but is there a way to pass "class" type through a regular function's parameters with out using templates. I wont use conditions or strings or class IDs. Just need to know if the compiler has a mechanism (C++) for passing class types. (No templates either) Thanks. Pass the RTTI type info... void function(const type_info &info) { //.....something here } function(typeid(classname));
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!