Skip to content

C / C++ / MFC

C, Visual C++ and MFC discussions

This category can be followed from the open social web via the handle c-c-mfc@forum.codeproject.com

111.5k Topics 465.7k Posts
  • How to Mix MFC Controls and OpenGL?

    c++ graphics game-dev tutorial question
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • OpenGL control on split MFC form

    graphics question c++ game-dev testing
    3
    0 Votes
    3 Posts
    0 Views
    B
    ??? Richard, Was this post meant for me? I NEVER use OnDraw directly, and my App is not at all based on Code Project Articles! I am just feeling around on my own, to solve a particular problem. If it IS meant for me a sentence containing "Wrong End" and "Stick" springs to mind! About Code Project Articles, I Only suggested, that, if I ever get this to work, that it merits me submitting an article about how to avoid the pittfals! :) Bram van Kampen
  • Default argument for DISP_FUNCTION_ID

    c++ java com tools tutorial
    2
    0 Votes
    2 Posts
    0 Views
    B
    Well, I Know very little about Java, and this is an MFC/CPP Forum. In CPP a default argument is declared in the function declaration in a class, as in class CMyClass{ int MyFunct(int Arg=0);}; This is a Declaration that MyClass has a Method named'MyFunct', which returns an int, and Optionally takes a Parameter (Arg), and, that when I call this function without a parameter, that 0 will be assumed. You make those declarations in a 'Header File' You Implement the function in the Implementation File,(Typically a CPP File) were you actually Implement the function: int MyClass::MyFunct(int Arg) if(Arg==0)return 1; else return 2; } The above means that when using the class, you write: MyClass myclass;// Instantiate the class. myclass.MyFunct();//Will return 1, an Argument 0 is assumed myclass.MyFunct(0);// will return 1, the Argument 0 is specified myclass.MyFunct(12);//returns 2, as per Calculation, Arg !-0 Your Marshalling Software beteween Java and CPP should give more details. :) Bram van Kampen
  • MFC Fragility to multiple threads

    c++ question announcement
    7
    0 Votes
    7 Posts
    0 Views
    B
    Well, Is this a Fragility a feature of MFC, and from how it wraps the SDK functions, or, is this a Feature that is Central to Windows, (i.e. the SDK suffers from the same problem) I have read several articles about this, and, the Gist is that it is always unsafe to communicate between two threads. This is clearly to conservative, Microsoft manages it quite well in for instance their MS Office Products. Thanks for your Interest. :) Bram van Kampen
  • Non display characters for selection count

    21
    0 Votes
    21 Posts
    0 Views
    L
    EM_GETSELTEXT is explicit This message returns the number of characters copied, not including the terminating null character. The call is terminated by the null character and if you have CR,LF they will count as characters The return is a CHARACTER COUNT, if your edit box is unicode mode it still reflects the character NOT THE NUMBER OF BYTES. Hence when providing a buffer you are best to use an array of TCHAR rather than a standard byte array to allow for size difference. Also note when size a TCHAR array use _countof DO NOT use sizeof for the same reason. Standard unicode aware coding practice. Several of the comments have confusion between CHARACTER and BYTE within the meaning of the windows API. No such confusion exists. In vino veritas
  • confused in static member function of class.

    c++ help
    3
    0 Votes
    3 Posts
    0 Views
    M
    thank you so much for clearing my doubt
  • How Much of WM_USER+X is used by MFC

    c++ lounge workspace
    9
    0 Votes
    9 Posts
    1 Views
    V
    WM_APP (Windows)[^]
  • Ensuring code runs synchronously

    4
    0 Votes
    4 Posts
    0 Views
    B
    No, It is NOT, and I explained that already! However, I also answered your other question, in quite a lot of detail. Before you can attempt to learn MFC Multi Threaded Programming, you will need to learn basic MFC Programming, and elements of the Windows SDK. MFC is a thin wrapper around the Windows SDK. Sometimes you need the real thing! Definitely needed in Multithreading. Cannot Help it, You need to study more before we can help you. Bram Bram van Kampen
  • Assertion failure While Editing CTreeView Label.

    help c++
    4
    0 Votes
    4 Posts
    1 Views
    _
    You should avoid overriding PreTranslateMessage ... in your case, you can solve more elegant your task overriding WM_CUT[^], WM_COPY[^], and WM_PASTE[^].
  • Application crashes on calling OnPaint() function!?

    c++ visual-studio question
    6
    0 Votes
    6 Posts
    2 Views
    L
    Well, you need to rethink your design. You should collect all the information related to the drawing as a result of user interaction, file processing etc. You then call InvalidateRect to tell Windows that your data has changed, and your window/client needs to be repainted. Then in the control you call your paint function in response to receiving a WM_PAINT message. It is at that point that you draw your lines, shapes, text etc.
  • 0 Votes
    8 Posts
    0 Views
    J
    std::find is a function to search for an identical value of a specific type. If you have different types it won't work. This includes arrays of same type but different length. What you are probably looking for is some kind of 'contains' (like strstr) or 'begins with' (like memcmp and strncmp with length of searching value) function which you have to implement yourself. Example: for (int i = 0; i < m_vec.size(); i++) { if (MySearch(m_vec.at(i), searchValue)) { // found break; } }
  • 0 Votes
    3 Posts
    0 Views
    D
    Le@rner wrote: this is slow in process. How are you measuring this? Le@rner wrote: please help anyone to execute query to fetch,insert or update record record in table. Did you bother to read the docs? They'll answer most, if not all, of your questions. I have an article here that shows how to create a read-only recordset. Other articles here. "One man's wage rise is another man's price increase." - Harold Wilson "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
  • Opening a Second File from Explorer

    csharp c++ visual-studio tutorial question
    7
    0 Votes
    7 Posts
    2 Views
    W
    It took me a few days to get back to this, then I ran into a few dead ends before hitting on the solution to get IDropTarget to work for my application. In the end Michael Dunn's article from here on CodeProject: was the best way forward. However once I got IDropTarget working, I ended up discovering my original problem had to do with locking my app down to one instance. A couple of years ago when this project was still in its infancy I used PJ Naughter's CSingleInstance class () to check and see if there was an instance of the program already running and if there was, switch to that instance. A second instance would start when I double clicked on a file associated with the program when an instance was already running. When the second instance is detected, it sends a message to the original instance to take focus and quits. PJ Naughter conveniently created a means to send the command line from the second instance to the first before quitting, so I took advantage of that and now the first instance loads the file correctly on double click. Implementing IDropTarget in the end turned out to not be necessary, but it will be a nice feature to allow users to drag and drop files into the program. It also expanded my understanding of COM, which I may need to understand better down the road. I need to do a lot of communication between programs as part of this project and I will need to do a lot more inter-program communication down the road. Just thought I would post an update for future reference if someone comes across a similar problem in the future and finds this thread. Thanks for the help!
  • 0 Votes
    1 Posts
    0 Views
    No one has replied
  • Passing macro parameters via function

    help
    8
    0 Votes
    8 Posts
    1 Views
    L
    :((
  • Template class with variadic arguments

    c++ wpf com hardware tutorial
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • AT command serially via C code

    tutorial
    2
    0 Votes
    2 Posts
    0 Views
    J
    Windows: Serial Communications[^] Linux: http://www.tldp.org/HOWTO/Serial-Programming-HOWTO/[^] and Serial HOWTO[^] Micro controllers: See the UART section in the data sheet and check if the manufacturer provides an application note about serial communication.
  • 0 Votes
    5 Posts
    0 Views
    V
    Is there any kernel equivalent of this method? I can see IoVolumeDeviceToDosName(), not sure. if this is correct one.
  • 0 Votes
    5 Posts
    0 Views
    L
    I tried CrystalBall 1.1 but its all blurred. :laugh:
  • where "FindFirstFile" fetch drive information ?

    windows-admin json question
    3
    0 Votes
    3 Posts
    0 Views
    D
    That's part of the underlying file system, be it FAT32 or NTFS. See here for the latter. "One man's wage rise is another man's price increase." - Harold Wilson "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles