I have a CDialog derived dialog which has a CFormView derived member which has a number of CEdit derived controls placed on it.
Based on business rules at runtime one of the CEdit derived controls should receive the focus when the dialog is displayed. In the OnInitialUpdate override of the CFormView derived class the specfic control is determined and focus is set to that control with the following call:
When the dialog is displayed there is no caret displayed within the control. It is outlined in the blue colour showing that it has focus, if I start typing the text is displayed but still no caret. If I TAB to the next control the caret is displayed there and if I TAB back it is now displayed in the originally focused control.
Alternatively, after the dialog is initially displayed and the caret is not showing If I shift the active window to another app (e.g. visual studio) and then actiavte the app again then the caret does appear in the CEdit control.
Any suggestions as to how I can ensure that the desired CEdit control receives focus on display of the dialog and that the caret is displayed?
I stated that the focus edit is being set from the OnInitialUpdate override of the CFormView derived class, I should have clarified that this has been called from the CDialog OnInitDialog method via a call to
this pBuffer NULL tell me that I am not able to read that sectors ... why ? The program is running as admin and sVolume is feed by _T("\\\\.\\F:"), first TRACE macro printed is a prove that is OK that part. SetFilePointer is used to position the reading part, and I intend to setup offset to the beginning, right ?
Your pBuffer value is NULL, so you are trying to read data into the memory address 0 - you have to allocate some space to read the data into and use that for your pBuffer value. For 512 bytes a stack-based array should do the trick.
pBuffer NULL tell me that I am not able to read that sectors
No, pBuffer = NULL; tells you that you have not allocated any space to pBuffer. And don't use void* unless you are trying to allocate nothing.
You can allocate space either of the following ways.
unsignedchar* pBuffer = newunsignedchar[dwLen]; // allocate some space for the data to be read into// orunsignedchar buffer[dwLen]; // allocate on the stack
ReadFile(hVolume, buffer, dwLen, &dwNum, NULL);