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
    20 Posts
    0 Views
    H
    Great response! Thanks!
  • Toolbar for bottom split window - CSplitterWnd

    c++ question
    8
    0 Votes
    8 Posts
    2 Views
    V
    Anu_Bala wrote: Im invoking this TrendListView as follow void CMainFrame::OnTrendListView() { // TODO: Add your command handler code here iGraphView = 0; //Code added by Mohan //Graph view inactive if( pTrendListDisplayFrame == NULL ) { iWindowNumber = 11; CDocTemplate *pTemplate = theApp.pTrendListViewTemplate; CCS3OprDoc* pDoc = new CCS3OprDoc; pTrendListDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNewFrame( pDoc ,NULL ); if( pTrendListDisplayFrame == NULL ) { AfxMessageBox( "Unable to Create Tuning Display" ); return; } pTemplate->InitialUpdateFrame( pTrendListDisplayFrame ,NULL ); } else MDIActivate( pTrendListDisplayFrame ); } What is the theApp.pTrendListViewTemplate? How is it defined/initialized?
  • academic question - usage of class variable

    question
    7
    0 Votes
    7 Posts
    0 Views
    S
    Generally, if you define a member variable of a class, this variable should only be accessed by member functions of that class (or derived class). This is true both for static and non-static member variables. If you need to read or change them from outside the class, define accessor member functions as needed. Any static or non-static function can and may access any member variable. Therefore there is no need to pass it to such a function, unless it is a non-static member variable of a different instance of the class. Example: class Vector3i { private: std::array data; public: // example 1: change own member variable void fill(const int value) { data.fill(value); } // example 2: change member variable from another instance void swap(Vector3i& other) { std::swap(data, other.data); } }; GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
  • 0 Votes
    8 Posts
    0 Views
    Q
    @leon de boer, @CPallini, @Joe Woodbury, Thanks for the your responses!
  • Changing CMainFrame Minimize ICON

    c++
    5
    0 Votes
    5 Posts
    0 Views
    F
    I was able to modify the first 8 resolutions but for the last 5 the drawing tool bar gets grayed out
  • Usage of bitset ?

    css hardware data-structures question
    5
    0 Votes
    5 Posts
    0 Views
    V
    Thanks, this will definitely give me a good start in using bitset, specially when I need to process more than two characters. Appreciate it. At current I have this code to process single char. // build a common function to set / reset bits // shift data into correct bit postion cout << " data 0x" << hex << +data << endl; data <<= iLSbit; cout << " shifted data 0x" << hex << +data << endl; int iDataBit; for (int iBit = iLSbit; iBit != iMSbit + 1; iBit++) { #ifdef DEBUG cout << "processing bit " << dec << +iBit << endl; // clear bit buf[0] &= ~(1UL << iBit); // don't need this #endif // set or reset bit // check data bit @ position iDataBit = (data >> iBit) & 1U; #ifdef DEBUG cout << " iDataBit " << hex << +iDataBit << endl; #endif if (iDataBit) { #ifdef DEBUG cout << "set bit @ position " << dec << iBit << endl; #endif buf[0] |= (1UL << iBit); } else { #ifdef DEBUG cout << "clear bit @ position " << dec << iBit << endl; #endif // clear bit buf[0] &= ~(1UL << iBit); } } Since I need to read the data (hardware register ) before modifying it , then writing it back to hardware it seems simpler than using bitset. At present I am modifying / checking single register parameter ( A/D converter input MUX ) , but in future I like to modify all parameters in single access. I think that is where bitset will do the job. Thanks again Cheers Vaclav
  • VC++ 2017 redistributables versions.

    c++ windows-admin question announcement workspace
    4
    0 Votes
    4 Posts
    0 Views
    V
    I'm glad it helped you! :)
  • 0 Votes
    2 Posts
    0 Views
    V
    manoharbalu wrote: When I call this function inside a thread, the application crashes by triggering a breakpoint. You must not directly access the main GUI thread controls from within a secondary thread! Instead you should PostMessage a user defined message to the main thread window notifying it that it has to do some operation(s). Within the main thread you handle this message and perform the ordered operation(s). See also this great J.Newcomer essay: [Using Worker Threads](http://www.flounder.com/workerthreads.htm)
  • 0 Votes
    3 Posts
    0 Views
    L
    To do it by polling which you sort of imply with your pseudocode (It is better with interrupts if possible to trigger the 1 event). You define an ID for the timer and a timer sample count #define IDT_TIMER_0 WM_USER + 100 UINT sampleCount = 0; You set the timer interval SetTimer(IDT_TIMER_0, 10, NULL);//10ms poll x 30 samples = 300ms You do the checks in on_timer call back function and reset the sample count if you find what you wanted void OnTimer (UINT TimerVal) { sampleCount++; if (sample_whatever == 1) { // output your 1 sampleCount = 0; } else if (sampleCount == 30) { // output your 0 sampleCount = 0; } } You can use KillTimer with the id to kill the timer at any time you like KillTimer(IDT_TIMER_0); There are more advanced techniques like using WaitForSingleObject but we need to know more about what the 1 is coming from. In vino veritas
  • Seperate source code for the tokens in the compiler c++

    c++
    3
    0 Votes
    3 Posts
    0 Views
    J
    If you are asking about compiler theory then in terms of creating a compiler there is often a 'tokenizer' as part of the process and to a certain extent it is often compartmentalized into its own section. If you are asking for code to do that then I can only suppose it is for a class and I suggest you get writing. Especially since such classes should only be taken by those with a significant technical degree in progress and knowing how to do that would be if not fundamental then at least significant as part of the career for that degree.
  • 0 Votes
    1 Posts
    0 Views
    No one has replied
  • Re initializing an array in C++ ?

    question c++ data-structures tools learning
    11
    0 Votes
    11 Posts
    0 Views
    U
    This is really a serious issue for c++ beginners as I am finding it very tough during my initial stage of the developer. printer offline fix helped me to get the detail of this. Now i finally able to do initialization.
  • Postmessage Not Working With WH_GETMESSAGE-MFC

    c++ help question
    5
    0 Votes
    5 Posts
    2 Views
    L
    First PostMessage returns a result and check the value of the message handle before the dispatch ... act like a programmer, you can easily give us a hell of a lot more information than you have. At a guess the window you are sending it to is not active or the window you are trying to post from is a dialog in the modal state. Can't tell much beyond that you haven't explained or given us enough detail. In vino veritas
  • C programming Question on Characters

    question
    7
    0 Votes
    7 Posts
    1 Views
    D
    You could (possibly) simplify to something like: int upper = 0; int alpha = 0; int digit = 0; ... if (isupper(pwd[x])) // this does not check for special characters upper = 1; else if (isalpha(pwd[x])) alpha = 1; else if (isdigit(pwd[x])) digit = 1; ... if (upper == 1 && alpha == 1 && digit == 1) printf("Requirements have been met.\n"); else printf("Requirements have NOT been met.\n"); "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
  • Getting value from DataGridView

    help
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Transfer from c to c ++

    com help tutorial
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Spurious end of file error from ifstream::read

    help c++ css ios com
    2
    0 Votes
    2 Posts
    0 Views
    L
    Hex 1A (equivalent to Ctrl-Z) is an end of file byte in a text file. You need to change your code so that you open the file in binary mode.
  • Placing the dialog bar

    15
    0 Votes
    15 Posts
    0 Views
    M
    Sorry for that. As you said I will refer google. Thanks
  • 0 Votes
    10 Posts
    2 Views
    L
    Ooh, that's a bit unexpected. :-O
  • eliminating lag from a chess clock

    game-dev announcement
    8
    0 Votes
    8 Posts
    0 Views
    D
    I'm happy to have helped. Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.