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
D

Dennis L

@Dennis L
About
Posts
83
Topics
55
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Thread Question
    D Dennis L

    I have placed the Sleep in the progress callback function as:

    bool DataCryptMain::ProgressBarProc(PRBDATA *prbdata)
    {
    ...
    Notify_Progress_GUI(NOTIFY_PROGRESS_RUNNING, NULL, (LPARAM)_prbdata);
    Sleep(1);
    }

    You said: "Try to decrease the number of messages sent to your GUI, for example, send only every 10th status report, or check when you sent the last report and if a given amount of time (like,for exaple 100 ms) didn't ellapse yet then skip sending the message, OR perform the percentage calculation in your thread and only send a message towards the GUI if the new percentage is different from the previous one, this should reduce the messages heading towards the GUI to not more than around a 100 messages per run, which shouldn't be too much, unless you are some very low end hardware" All these i'll try them by using PostMessage or SendMessage?

    C / C++ / MFC question help

  • Thread Question
    D Dennis L

    If it works as i've shown it uses about 86% of CPU, the changes are displayed but I can't, for example, move the window or push a button. If i place a sleep function then it works OK About the first you'said, i didn't understand "you might find out what your GUI thread seems to be waiting for"

    C / C++ / MFC question help

  • Thread Question
    D Dennis L

    The code is:

    // When user presses the start button
    void DataCryptMain ::ProcessCrypt()
    {
    ...
    cryptthread.Start(_staticThreadProc, this)
    ...
    }

    // Crypt procedures
    DWORD WINAPI _staticThreadProc(LPVOID lpData)
    {
    DataCryptMain *dcr = reinterpret_cast(lpData);
    return dcr->CryptThreadProc(NULL);
    }

    DWORD WINAPI DataCryptMain::CryptThreadProc(LPVOID lpData)
    {
    int iErrorOrInfo = INFO_PROCESS_DONE;

    // Ciphering stuff
    iErrorOrInfo = CryptoRijnDaelProcess();

    Notify_Progress_GUI(NOTIFY_PROGRESS_END, NULL, iErrorOrInfo);

    return 0;
    }

    // Notify GUI
    void DataCryptMain::Notify_Progress_GUI(int iNotificationType, WPARAM wParam, LPARAM lParam)
    {

    if (iNotificationType == NOTIFY_PROGRESS_RUNNING)
    {
    PostMessage(hWnd, WM_PROGRESS_RUNNING, wParam, lParam);
    }
    else
    {
    PostMessage(hWnd, WM_PROGRESS_END, wParam, lParam);
    }

    }

    // Call back procedure from inside Encrypt()
    bool _ProgressBarProc(PRBDATA *prbdata)
    {
    DataCryptMain *dcr = reinterpret_cast(prbdata->lpOtherData);
    return dcr->ProgressBarProc(prbdata);
    }

    bool DataCryptMain::ProgressBarProc(PRBDATA *prbdata)
    {
    if (cryptthread.WaitToExit()) return TRUE;

    PRBDATA *_prbdata = new PRBDATA;

    memcpy(_prbdata, prbdata, sizeof(PRBDATA));

    Notify_Progress_GUI(NOTIFY_PROGRESS_RUNNING, NULL, (LPARAM)_prbdata);

    return FALSE;
    }

    // Rijndael processing
    int DataCryptMain::CryptoRijnDaelProcess()
    {
    int iErrorOrInfo = OK;

    RijnDaelCrypto *rdc = new RijnDaelCrypto;

    ...
    ...

    // Set progress bar function
    SetProgressFunc(_ProgressBarProc, (LPVOID)this);

    ------------------- Here this function loops through the file encryption
    if (rdc->Encrypt(wcgFileNameIn, wcgFileNameOut, cryptParams.iCipherMode) < 0)
    iErrorOrInfo = ERR_PROCESS_STOPPED_BY_USER;

    _DELETE(rdc);

    return iErrorOrInfo;
    }

    //WM_PROGRESS_RUNNING
    bool DataCryptMain::OnProgressRunning(WPARAM wParam, LPARAM lParam)
    {
    float fPercent[3];
    char sTemp[64];

    PRBDATA \*prbdata = reinterpret\_cast(lParam);
    
    // Percent % read file
    fPercent\[0\] = ((float)prbdata->iReadBytesIncByFuncRead / (float)prbdata->dwSize) \* 100.0f;
    // Percent % block/s processed
    fPercent\[1\] = ((float)prbdata->iBlocksIncrement / (float)prbdata->iBlocksNum) \* 100.0f;
    // Average percent
    fPercent\[2\] = (fPercent\[0\] + fPercent\[1\]) / 2;
    
    SendDlgItemMessage(hWnd, IDC\_PROGRESSSTATUS, PBM\_SETPOS, (WPARAM)fPercent\[2\], 0);
    
    // Display progress bar's percent value
    sprintf\_s(sTemp, "%0.1f %%", fPercent\[
    
    C / C++ / MFC question help

  • Thread Question
    D Dennis L

    Hi all! I'm on a ciphering Win32 project and i have the following problem: I have created the thread and I don't use SendMessage calls inside the thread procedure. I use PostMessage with user defined messages to display progress information on the main window. But when the thread starts the whole program dead locks. Is that means that it needs a Sleep function or something else that you could suggest me? Thanks!

    C / C++ / MFC question help

  • Hi all!
    D Dennis L

    Hi All! I'm creating a project and i'd like someone to tell me a way to change multiple controls properties (ie: Enable, Display, Change texts ...) whenever i click on different tree items. Is it ok to use EnumChildWindows? Or is there any other method? Thanks for any reply!

    C / C++ / MFC data-structures question

  • Two way class access
    D Dennis L

    Hi all! I have the following class and i want a way to make the tree, and edit controls to have access to MAINCLASS variables. a. Is that OK to create a constructor to each one of the controls to pass a parameter something like Window* wn; And use it as ((MAINCLASS *)mainwindow)->a; within class implementation ? Or can you suggest me an other OOP way because i have read somewhere that this way to convert a base class object (mainwindow) to a derived class object is not so legal? class MAINCLASS: public window { ... ... public: //constructor //destructor MyTreeCtrl tc; MyEditCtrl ec; ... ... public: // Variables int a; } a. // in MyTreeCtrl h class MyTreeCtrl { ... ... public: MyTreeCtrl(Window* wn) void Foo(); ... ... public: // Variables Window *mainwindow; }; // in MyTreeCtrl cpp MyTreeCtrl::MyTreeCtrl(Window* wn) { mainwindow = wn; } MyTreeCtrl::void Foo() { ... int b = ((MAINCLASS *)mainwindow)->;a ... } Thanks!

    C / C++ / MFC c++ data-structures question

  • Tree view Question
    D Dennis L

    Hi All! I want on a tree control (under Win32 SDK) to retrieve item text by using NM_CLICK notification. The problem i have is when I use NM_CLICK I retrieve NULL at HTREEITEM handle (I checked with NM_DBLCLK and i retrieved a handle). would it be good idea to use TVHITTESTINFO with TreeView_HitTest? The code is: ... case NM_CLICK { char str[32]; int ret = 0; TV_ITEM item; HTREEITEM hItem = NULL; // Get next selected item // When i use NM_DBLCLK hItem is not NULL<------- hItem = (HTREEITEM)TreeView_GetNextItem(hTree, hItem, TVGN_CARET); if (hItem == NULL) ret = 0; item.mask = TVIF_TEXT; item.cchTextMax= 32; item.pszText= str; item.hItem = hItem; if (!TreeView_GetItem(hTree, &item)) ret = -1; } Thanks

    C / C++ / MFC question data-structures help

  • TreeView question [modified]
    D Dennis L

    I have done this but it doesn't work it works only if i use NM_DBLCLK.

    C / C++ / MFC question data-structures tutorial

  • TreeView question [modified]
    D Dennis L

    Hi all! Can anyone tell me how to retrieve item data from a tree when I use NM_CLICK? Thanks!

    modified on Friday, August 22, 2008 12:41 PM

    C / C++ / MFC question data-structures tutorial

  • Memory allocation
    D Dennis L

    I think i got it now Thanks for your reply!

    C / C++ / MFC performance help question

  • Memory allocation
    D Dennis L

    first I have read that all local variables that are not initialized explicitly are being intialiazed to 0xcccccccc with the Microsoft compilers. The first OK but the other two? second what happens with this address if the program exits or is this void func1() { SOME *sm = new SOME; delete sm; } void func2() { func1(); // What happents here? }

    C / C++ / MFC performance help question

  • Memory allocation
    D Dennis L

    first: in that below, why the memory addresses of s0, s1, s2 are different and has these values 0xcccccccc { s0=0xcccccccc s1=0xcccccccd s2=0xcccccccf } second: after deallocation the memory addresses are still assigned to s0, s1, s2 0x00332e98 { s0=0x00332e98 "" s1=0x00332e99 "3" is that a problem s2=0x00332e9b "" }

    C / C++ / MFC performance help question

  • Memory allocation
    D Dennis L

    Hi every one! Can any one explain me why is this happening struct SOME { char s0[1]; char s1[2]; char s2[1]; }; int main() { SOME *sm = new SOME; delete sm; return 0; } before allocation (with new) 0xcccccccc { s0=0xcccccccc s1=0xcccccccd s2=0xcccccccf } after allocation 0x00332e98 { s0=0x00332e98 " π­Ί««««««««ξώξώ" s1=0x00332e99 "π­Ί««««««««ξώξώ" s2=0x00332e9b "Ί««««««««ξώξώ" } after deallocation (with delete) 0x00332e98 <----- Is that a problem? { s0=0x00332e98 "" <----- s1=0x00332e99 "3" <----- s2=0x00332e9b "" <----- } thanks!

    C / C++ / MFC performance help question

  • structure questions
    D Dennis L

    Maybe i didn't ask right the question. I know the difference between KEY k; and KEY *k; but i really care that the fact *k is allocated in free memory has some advantages?

    C / C++ / MFC

  • structure questions
    D Dennis L

    Sorry! If KEY is a private member? Or what if i do it like class MYCLASS { ... ... public: void Get(KEY *k); ... }; // in cpp void MYCLASS::Get(Key *k) { // Do operation: } int main() { MYCLASS g; KEY k; // key is empty g.Get(&k); //key is filled // Do operations with k return 0; }

    C / C++ / MFC

  • structure questions
    D Dennis L

    What is the difference to use it as KEY k; and KEY *k; I have read some papers that say that there is speed difference or some kind of difference in memory. (if i remember well) Or what is the difference anyway?

    C / C++ / MFC

  • structure questions
    D Dennis L

    About the OO safe question i will use it like: class MYCLASS { ... ... public: KEY k; or KEY *k; ... };

    C / C++ / MFC

  • structure questions
    D Dennis L

    I mean safe by the fact that these arrays are big and many, or would it be a problem in memory ? Also is it Thread safe?. And is it OO safe because i will use it in a class Thanks!

    C / C++ / MFC

  • structure questions
    D Dennis L

    Hi every one! Is this a safe way to define key structure.If not then how'd it be safer Thanks! typedef struct _key { struct p1 { struct p2 { unsigned char a1[128]; unsigned char a2[8]; }; unsigned char b1[64]; unsigned char b2[64]; unsigned char b3[128]; unsigned char b4[64]; unsigned char b5[64]; unsigned char b6[64]; }; } KEY;

    C / C++ / MFC

  • try catch question
    D Dennis L

    Hi all! Can anyone tell me if i could use try-catch block within a windows procedure to catch errors like "Error occurred while creating window!" or "Couldn't initialize COM object!" for example my in winmain function: try { SetupMessageBoxPointer(); // Initialize WinSock for peer to peer classes, and COM for ... if (!InitializeWinSock2()) throw Error(L"Error: Cannot initialize Ws2_32.dll!", _FATAL_ERROR); if ((hOK = CoInitialize(NULL)) != S_OK) throw Error(L"Error: Cannot initialize COM object!", _FATAL_ERROR); mainapp = new DataCrypt(hInstance); if (mainapp == NULL) throw Error(L"Cannot allocate memory for DataCrypt object!", _FATAL_ERROR); mainapp->Initialize(); mainapp->Run(); // messages loop } catch(Error &err) { ERRORMSG(NULL, err.GetText(), err.GetErrorType()); }

    C / C++ / MFC com performance help tutorial question
  • Login

  • Don't have an account? Register

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