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
  • 0 Votes
    4 Posts
    0 Views
    L
    As per Jochen's answer but I would also add a guard against your forgetting to set the pointer checking it's not NULL. The typecast and advance definition is also unnecessary unless you actually need the type for something, the pointer will be checked for match when you attempt to set it with or without the typecast. void MyClass::Act(void* pData){ if (m_pfnDoSomething) m_pfnDoSomething(pData); } Here is a minimalist function ptr .. no need for forward delaration, typedef or even a name of field. All you need is the * dereference before the function ptr name it knows what you are doing from that and really all it needs is what the function looks like so when you try to set it, that it checks for match. class MyClass{ void(*MyClass::m_pfnDoSomething)(void*); void MyClass::Act(void\* pData){ if (m\_pfnDoSomething) m\_pfnDoSomething(pData); } }; Finally especially since your in a class I would suggest you don't pass in the void* data pointer but look at other options to typecast or marshal the data in a way that is a little safer. In vino veritas
  • 0 Votes
    5 Posts
    0 Views
    L
    Sorry, what do you mean by 'correct'? All the examples are correct, in that they declare the value as zero.
  • Copy certain member variable data of a structure

    performance help tutorial
    12
    0 Votes
    12 Posts
    0 Views
    L
    I was thinking a bit more about your problem and there is a possible all be it highly technical solution which is a thing called a file filter. It jogged my interest as to whether you could run a memory mapped file in a file filter so you can get all the raw file access commands and it appears you can Memory Mapped Files in a File System Filter Driver[^] It wouldn't be trivial but you would know exactly what and where is being written by the model program to the memory mapped file to then duplicate and send to your client. In vino veritas
  • Edit Subitems In Owner Drawn List

    announcement
    7
    0 Votes
    7 Posts
    1 Views
    B
    You must be desperate, seeing that you reverted to the SDK! Been there too, more than once! Did you set the item(s) specifically as 'Owner Draw' in the Resource Editor! If you did not, all the above quoted messages will end up in the 'Bit and Byte Bin', in the nearest toilet! Hope this is helpful, :) Bram van Kampen
  • for project

    linux xml tutorial question
    5
    0 Votes
    5 Posts
    0 Views
    B
    Hi, Well, you have to write the Content! I have no idea of your compiler environment, but, for starters you need to create or select a folder and a File, where the resulting code will be stored. These files would have a 'htm' or 'html' extension. Most environments I know create the Headers and Footers for a blank Page. You have to write the content of the Page in between. You can inspect your work by opening it in Internet Explorer. Bram van Kampen
  • 0 Votes
    3 Posts
    0 Views
    B
    I recommend that you read the many books written by Matt Pietreck on the subject. Even books about Win98 or XP will do. They are Classics, but, explain the lot, in your case in particular, how executable files are mapped to memory. I think that this forms part of the foundation every software engineer should have at his finger tips. Matt wrote several books about spelunking in the bowels of the various windows versions. However User Beware! If you are just interested in how your windows version on your computer does things, read, spelunk, and learn! If you start writing software on the basis of what you learn there, BEWARE! It will work, without doubt on Your computer(where you did the Spelunking!) There is absolutely no guarantee that it will work on any other computer, nor, that it will work after the next windows update! Microsoft provides a large API (Application Program Interface), which Microsoft guarantees to support over the various upgrades. Doing things outside this interface, will sooner or later lead to disaster. Regards, :) Bram van Kampen
  • C++ Smartphone application, get data from MySQL

    database c++ android ios mobile
    7
    0 Votes
    7 Posts
    0 Views
    D
    I was thinking the same thing. :thumbsup: "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
  • 0 Votes
    1 Posts
    2 Views
    No one has replied
  • 0 Votes
    1 Posts
    0 Views
    No one has replied
  • ShellExexute to open the default browswer

    csharp visual-studio com help question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • 0 Votes
    14 Posts
    0 Views
    L
    Okay 1 polled 4 state parser code .. I commented it so you can follow what its doing. The parse buffer is 4K so you need to poll min rate of 20-30 times a second. You can increase or decrease the parse buffer size and change the poll rate requirements. Just remember your 90K data/ parse buffer size = min poll rate you need. You can use a timer or hook into the MFC message system to fire of a poll request ... personally I would use a timer. If its just writing the data to a file or something you could just loop the poll call in a thread. The data body is available in the dataReadyState and you haven't indicated what you do with it so its blank. The parser just cycles an maintains and cleans its own buffers. enum ReadParseStatus { readSigState = 0, readDataSizeState, readDataBodyState, readDataAvailState }; // This is some unique signature make it what you like // It should be something unlikely to occur in the data itself // Make sure the server sends an identical signature and the data size before each packet body const char signature[] = "PACKETSIG%$#"; // Parse status always starts as read signature enum ReadParseStatus parseState = readSigState; // Parse buffer char parseBuffer[4096]; // The parse buffer itself ... you may adjust this up or down depending on poll rate int parsePos = 0; // Position of parse buffer long bodyDataSize = 0; // Body data size for current packet unsigned char* bodyData = NULL; // Body data storage long bodyDataPos = 0; // Body data position // Parses socket receive data BOOL Poll_Receive_Data (CAsyncSocket sock){ // Read whatever data is available into the parse buffer up to parse buffer full // sock would be m\_pSocket in your code int iResult = sock.Receive(&parseBuffer\[parsePos\], sizeof(parseBuffer) - parsePos); // If return is zero or less there is either no data of something is wrong // So return a false so caller knows and can do something if (iResult <= 0) return (FALSE); // Adjust the parse position so space in buffer left can be checked parsePos += iResult; switch (parseState){ case readSigState: { // Temp buffer .. its 32 bytes here which must be bigger than signature length char tempbuf\[32\]; // Hold signature length we will use it a bit in this phase int siglen = strlen(signature); // Preset sigFound to false BOOL sigFound = FALSE; // Loop while signature not found and enough data to run signature test while ((sigFound == FALSE) &a
  • 8Puzzle game

    data-structures game-dev algorithms tutorial
    3
    0 Votes
    3 Posts
    0 Views
    D
    So did someone give you these two pieces of code? "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
  • 0 Votes
    6 Posts
    0 Views
    S
    create a struct data structure similar to: struct myPacket{ int uwSeq;// sequencing starts from 1 upto 879 int maxSeqCount;// when this reaches 879 reaset to 1 char myData[1024];//Small Chunk unsigned int uwcrcData;//CRC of uwSeq,myData }stSmallChunk; send stSmallChunk data packet and validate at other end using CRC recieved seqs. FYI: 1024*879 small chunks =900096 Bytes -Shyam Kodase
  • 0 Votes
    6 Posts
    0 Views
    L
    The easy solution is to override the read and write methods in your own stream extension. It is the "standard", "usual" and "prefered" way to fix behaviour of classes or objects with methods and functions that aren't exactly as you desire. Can I go so far as to suggest MovieNameStream as a possible title for the extension. In vino veritas
  • Edit Control Problem

    beta-testing json help question code-review
    18
    0 Votes
    18 Posts
    0 Views
    P
    The selPos and selEnd had actually referred to the precise character index of the selected text. Thanks.
  • 0 Votes
    4 Posts
    0 Views
    P
    You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect. The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect. Debugger - Wikipedia, the free encyclopedia[^] Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^] Patrice “Everything should be made as simple as possible, but no simpler.” Albert Einstein
  • Can someone simply explain defaulting arguments

    3
    0 Votes
    3 Posts
    0 Views
    A
    It's simply a means to provide values for the arguments that will be a good default (or starting point). For example, if let's say... you're opening a socket to provide some service. By default, most libraries will bind to any (or every) Ethernet address available on a system. Reason you'd want to do this is because you don't necessarily want to only provide the service on one Ethernet device but not the other (for example, servers have multiple Eth devices for load balancing). If however, you do only want the service to be provided on one device, then you can choose to bind to the specific Eth address of interest.
  • How to organize nested props in VueJS?

    tutorial question
    3
    0 Votes
    3 Posts
    0 Views
    R
    Thank you very much :)
  • Does wp_cache still load Wordpress and use MySQL?

    php mysql question
    2
    0 Votes
    2 Posts
    0 Views
    D
    See 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
  • 0 Votes
    2 Posts
    0 Views
    D
    Is this a C / C++ / MFC question? "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