Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
O

Oliver123

@Oliver123
About
Posts
80
Topics
51
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Capture Left Mouse [modified]
    O Oliver123

    1. Lets say I have a MFC SDI with a dialog containing 5 edit boxes. 2. I want to left click on any of the five edits and generate "Hello" in it. 3. I have reached the point where I can click anywhere on the dialog and generate "Hello" into one single edit box. 4. I haven't figured out how to determine if the click is in one of the edit boxes rather than anywhere in the dialog. 5. Then I need to know which edit box. So, I need advice on #4 and #5. Here is what I have: CTest.h afx_msg void OnLButtonDown(UINT nFlags, CPoint point); CTest.cpp BEGIN_MESSAGE_MAP(CTest, CDialog) //{{AFX_MSG_MAP(CTest) ON_WM_LBUTTONDOWN() //}}AFX_MSG_MAP END_MESSAGE_MAP() ... void CTest::OnLButtonDown(UINT nFlags, CPoint point) { CDialog::OnLButtonDown(nFlags, point); //this is anywhere on the dialog GetDlgItem(IDC_EDIT_C1L1)->SetWindowText("Hello"); //if I knew where it clicked, I could target correct editbox } Thanks

    modified on Tuesday, January 01, 2008 7:07:59 PM

    C / C++ / MFC c++ tutorial

  • Is floating point number mathematical integer?
    O Oliver123

    How can one determmine if a given floating point variable is a mathematical integer (1,2,3,4,5...)? I figured I could divide by one and check for zero as a remainder. Doesn't work. float fNumber = 861; float one = 1; fmod(fNumber, one) modf(fNumber, one) Both of these return a value of .9998936354755 (or some other decimal very close to 1). I've tried various combinations of float and double, but get the same results. Ideas? Thanks.

    C / C++ / MFC question

  • Dialog box with changeable STATIC text and TITLE
    O Oliver123

    This changes the dialog title caption from within the dialog class: CString windowCaption; windowCaption.Format("%s", SomeString); this->SetWindowText(windowCaption);

    C / C++ / MFC tutorial

  • MoveWindow()
    O Oliver123

    I want to change the position and size of a window. In the constructor of the Doc window of a VC++ SDI I have the following code. (I'd also like to do this in any window I make.) CSDITESTfDoc::CSDITESTfDoc() { MoveWindow(5,5,500,500,TRUE); } The compiler says MoveWindow does not take 5 paramaters. The format of the command is: void MoveWindow(int x, int y, int nWidth, int nHeght, BOOL bRepaint = TRUE) Where am I going wrong? Thanks.

    C / C++ / MFC c++ question

  • Dialog death
    O Oliver123

    What does clicking the "X" box in the upper right corner of a dialog do? I'm puzzled by the behavior I am observing, and would like to understand it better. Below I describe two situations with very different results which seem to depend on clicking that box. SITUATION A void CDlgControl::OnBUTTONCreateLadder() { pLD = new CLadder; } void CDlgControl::OnBUTTONTestButton() { pLD->DestroyWindow(); delete pLD; pLD = NULL; } In SITUATION A above, the dialog is created and displayed. Debug shows it progressing through each command in OnBUTTONTestButton(). Debug then traces it through many Windows functions until it finally reaches a window titled Disassembly where it fails on a command 7E41B517 call 7E4194A4 Debug assertion failure File Winocc.cpp When not using Debug, it simply fails on the same message SITUATION B The same exact code is used. However, prior to executing OnBUTTONTestButton(), I click the "X" box in the upper right corner of the CLadder window. Then I execute OnBUTTONTestButton(), and everything works just fine. QUESTION: What does that "X" box do? What makes SITUATION A different from SITUATION B? Thanks

    C / C++ / MFC question c++ debugging

  • Delete or Destroy?
    O Oliver123

    Which should I use to delete the instance of class CLadder? OPTION1 or OPTION2? Or something else? CLadder is a dialog class. //OPTION 1 CLadder* pLD; pLD = new CLadder: ... ... ... delete pLD; //OPTION 2 CLadder* pLD; pLD = new CLadder: ... ... ... pLD->DestroyWindow();

    C / C++ / MFC question

  • Class template argment list
    O Oliver123

    NOTE: In the following text and code I use [] rather than the greater than and less than signs because of the HTML editor. I read about class templates in three books and MSDN and thought I understood. So, I created a SDI test project in VC++ to learn about them. I added only this single CTestTemp class. As you can see, I didn't get far. The following code keeps giving me a C2955 (use of class template requires template argument list) error in TestTemp.cpp each place a function is defined (or BEGIN MESSAGE MAP). I have tried all kinds of argument lists in the constructor function, tried putting template[class T] in various places in the code, but nothing works. If I add a new function, the same error flags the new function. It appears I'm doing somehting wrong in the function definition. I'm at such a basic point, I figure I must be doing somehting equally basic wrong. Ideas? Thanks. //TestTemp.h template[class T] <--only thing I add class CTestTemp : public CWnd { public: CTestTemp(); virtual ~CTestTemp(); protected: DECLARE_MESSAGE_MAP() }; //TestTemp.cpp CTestTemp::CTestTemp() <---error C2955 { } CTestTemp::~CTestTemp() <---error C2955 { } BEGIN_MESSAGE_MAP(CTestTemp, CWnd) <---error C2955 //{{AFX_MSG_MAP(CTestTemp) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_MSG_MAP END_MESSAGE_MAP()

    C / C++ / MFC c++ html css wpf help

  • Pointer to Doc class of SDI
    O Oliver123

    I have an SDI and want to get a pointer to class SDIDoc. If I was creating a new class instance from within SDIDoc, I would do the following: SomeClass* pSC = new SomeClass; Then I would have a pointer pSC to the new instance of SomeClass. But, since SDIDoc already exists, and I am within SDIDoc, how do I get a pointer to SDIDoc? In SDIDoc.h I have the following: SDIDoc* pSDIDoc; In SDIDoc.cpp, I am looking for the following: pSDIDOC = ??????? Thanks

    C / C++ / MFC question c++

  • Scope of pointer to class instance
    O Oliver123

    If I define a variable in a function, its scope remains local to that function. Suppose I define a new instance of a class and a pointer in a function. Is the pointer local to the function? Can it be referenced outside the function? Do I have to declare the pointer in the header if I want to use it outside the function? For example: X::SomeFunction() { int ABC = 0; Y* pYY = new Y; //Creates new instance of class Y } Integer ABC is limited in scope to function SomeFunction(). Is there any limitation to the scope of pYY? Can pYY be used in any other function other than SomeFunction()? Thanks

    C / C++ / MFC tutorial question

  • User created WM_COMMAND message
    O Oliver123

    Is there way to create a WM_COMMAND message from within my code? In constructing a menu under SDI or MDI, one can: 1. Create a menu item. 2. Assign an ID to the menu item 3. Use Wizard to assign the ID to function in a class. I want to create my own WM_MESSAGE in my own code, assign an ID to it, and use Wizard to assign that ID to a particular function in a class. Is there a way to do this? Is there a way to do something similar to this? Thanks.

    C / C++ / MFC question

  • Header files #include problem
    O Oliver123

    I combined the header files and everything works. First I created class X with X.cpp and X.h Then created class Y with Y.cpp, but changed the default header file to X.h. So both class X and class Y had their headers in the same file. Forward reference worked. Both X and Y are created in Z. Z then passes pointers to X and Y by invoking a function of X and a function of Y. In X, a pointer to Y allows me to execute Y functions. In Y, a pointer to X allows me to execute X functions. The only peculiarity is when creating functions in Y. I right click Y in the class window in the workspace, then select ADD MEMBER FUNCTION. The new function is declared in class Y in file X.h, but the implememtation goes into X.cpp. Deleting the skeleton implementtion in X, and pasting it into Y.cpp solves the problem. Thanks for the help.

    C / C++ / MFC help question

  • Header files #include problem
    O Oliver123

    The fog begins to clear a bit. Question: In your example, all the statements are in one file. However, VC++ creates individual header files for each class. To emulate what you have shown, we would have to control of the order in whch the header files are presented to the compiler. Correct? Can we give the compiler the header.h files in the order it needs them while still maintaining the very convenient system of one header file per class? Is there a way to do this? Thanks

    C / C++ / MFC help question

  • Header files #include problem
    O Oliver123

    I did this, and it successfully compiled. Passed a pointer to class Y into class X. Passed a pointer to class X into class Y. When I try to use Y* in X, the compiler says Y is undefined. When I try to use X* in Y, the compiler says X is undefined. So, when using forward references, where does the compiler eventually get the definition of Y so it can be used as Y* in X? Is there some type of ordering of what is presented to the compiler? Thanks

    C / C++ / MFC help question

  • Header files #include problem
    O Oliver123

    Two classes X and Y. I want to #include X.h in Y.h I want to #include Y.h in X.h I can do one, but not both. I understand that there is a "self-referencing" situation happening here. What I don't understand is how I can work around this. What am I trying to do? Instances of both X and Y are created by an instance of class Z. I would like X to have a pointer to instance of Y. I would like Y to have a pointer to instance of X. In X I have a function that takes Y* as a parameter. Z executes it and that's how I get Y* into X. In Y I have a function that takes X* as a parameter. Z executes it and that's how I get X* into Y. This works when Y.h is included in X.h OR This works when X.h is includd in Y.h It will not work with both #includes. Ideas? Work arounds? Thanks

    C / C++ / MFC help question

  • Pass info class to class
    O Oliver123

    I tried this, but found I didn't really know what to load into the pointer. In CSDITest1Doc I entered the following code. I figured if I could get the pointer aDoc loaded with the address of the instance of CSDITest1Doc, I could call a function from CTestDlg, and use that to pass the pointer to CTestDlg. CSDITest1Doc* aDoc; aDoc = ??????? Is this a correct approach? Thanks

    C / C++ / MFC question tutorial

  • Pass info class to class
    O Oliver123

    Class CSDITest1Doc creates a new instance of a dialog class. Works OK. Example below: CTestDlg* aDlg = new CTestDlg(); //code is in CSDITest1Doc From class CSDITest1Doc I can execute functions of the new CTestDlg. For example, LoadMessage() is a function of CTestDlg. Works OK. Example below: aDlg->LoadMessage(); //this code is in CSDITest1Doc Sometimes I want to alert CSDITest1Doc of something that happens in CTestDlg. Sometimes I want CTestDlg to ask for data from CSDITest1Doc. Suppose XYZ() is a function of CSDITest1Doc. How do I execute a XYZ()of CSDITest1Doc from CTestDlg?

    C / C++ / MFC question tutorial

  • Dialog items maximum
    O Oliver123

    Is there a limit on the number of dialog items that can be put on a dialog in a single dialog application? How many edit boxes, buttons, etc?

    C / C++ / MFC question

  • Button down increment
    O Oliver123

    I want to create a button that will force an acton to continue as long as the button is "down." For example, I want to increment a displayed field by 1 as long as the button is down. I can increment each time the button is clicked, but can't hold it down and get multiple increments. What's the general approach to this? Thanks.

    C / C++ / MFC tutorial question lounge

  • Debug vs Release Configuration
    O Oliver123

    I'm not experienced enough to totally understand what you mean, but I gave it a try. I looked at PROJECT SETTINGS, and toggled between "Settings for Debug" and Settings for Release." Under tab LINK, GENERATE DEBUG and LINK INCREMENTALLY are checked. Under tab RELEASE, neither is checked. I didn't know where to look to check the settings for COMPILER. I did manage to solve the background color problem by setting the background in InitDalog, but the disappearing integers in the button text still have me stumped. thanks.

    C / C++ / MFC visual-studio debugging question announcement workspace

  • Debug vs Release Configuration
    O Oliver123

    I have a program working fine when active configuration is set to debug-I build it, then execute. When I change the configuration to release, it compiles OK, but when I execute it the background of the dialog turns black, and buttons that displayed integers display nothing. The buttons are set with GetDlgItem(IDC_BUTTON14)->SetWindowText(newText) Ideas? Thanks.

    C / C++ / MFC visual-studio debugging question announcement workspace
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups