|
Hi all!
I've a problem, and I didn't find any solution for it anywhere.
I've a dialog based app, which creates a CPropertySheet when a button clicked. I add pages to the sheet, then I call its DoModal.
The pages are derived from CPropertyPage. I've special pages, those put another window objects onto the page in OnInitDialog (I get some HWNDs, and then call ::SetParent(child_hwnd,GetSafeHwnd().
The window objects all have the WS_CHILD style, so the setparent works fine, the newly added child windows appears on the pages.)
Everything goes fine until I press OK.
I've debugged a bit, and found out that the code hangs, when the CPropertySheet's DoModal reaches a SetActiveWindow call. (When it wants to set the parent window as the active window again).
I did a not too nice trick: the main dialog catches the WM_ACTIVATE and doesn't call the DefWindowProc while the PropertySheet is visible. It worked, but I think there is a better solution.
Thanks in advance!
|
|
|
|
|
Created and editable CListCtrl.
Trying to subclass CDateTimeCtrl - unable to handle using VK_TAB and forcing the subclassed control to lose focus and destroy itself.
Reasoning: When using the drop-down, obviously, CDateTimeCtrl loses focus, but can't figure out how to keep control visible until all user intervention is complete - or naturally, it loses focus to the next column, or other object.
I tried overiding OnKillFocus:
void CdtkDate::OnKillFocus(CWnd* pNewWnd)
{
CDateTimeCtrl::OnKillFocus(pNewWnd);
CMonthCalCtrl* pMonCalCtrl = this->GetMonthCalCtrl();
// But CMonthCalCtrl doesn't get focus until the user selects it,
// Even though it is visible - should I force this focus?
if(pNewWnd->m_hWnd == pMonCalCtrl->m_hWnd)
return;
DestroyWindow();
}
This Class will not always destroy itself - and I get an error when the application instance is terminated.
Any suggestions will be appreciated.
|
|
|
|
|
Hi,
The below works ok for resizing a control within a window but a side effect is that the when resizing the main window I have to left click the mouse again to release the resizer, how do I make it auto release? (it auto releases the resizer when not using MoveWindow)
Thanks,
HOBNOB
void CConcatDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
RECT r;
GetWindowRect(&r);
if(r.top!=0)
if(m_list) m_list.MoveWindow(0, 55, r.right-r.left-7, r.bottom-r.top-130,TRUE);
}
|
|
|
|
|
Some settings in ur windows, nothing wrong with the code.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Hello, the following code always crashes with "Error: Attempt to access invalid address".
void CServicesDlg::OnBstop() <br />
{<br />
TRACE("Services::OnBstop\n");<br />
<br />
DWORD dwError;<br />
int nSel = m_ctlListServices.GetSelectionMark();<br />
<br />
if(nSel == -1)<br />
{<br />
return;<br />
}<br />
else<br />
{<br />
TCHAR szService[BUFF_LEN];<br />
m_ctlListServices.GetItemText(nSel, 1, szService, BUFF_LEN);<br />
<br />
SC_HANDLE hSCM = OpenSCManager(m_strPCName, NULL, SC_MANAGER_ALL_ACCESS);<br />
if(hSCM == NULL)<br />
{<br />
dwError = GetLastError();<br />
ErrorDescription(dwError);<br />
AfxMessageBox("OpenSCManager failed");<br />
TRACE("Services:hSCM is NULL\n");<br />
return;<br />
}<br />
SC_HANDLE hService = OpenService(hSCM, szService, SERVICE_ALL_ACCESS);<br />
if(hService == NULL)<br />
{<br />
dwError = GetLastError();<br />
ErrorDescription(dwError);<br />
AfxMessageBox("OpenSCManager failed");<br />
TRACE("Services:hService is NULL\n");<br />
return;<br />
}<br />
<br />
if(ControlService(hService,SERVICE_CONTROL_STOP,NULL)==0)<br />
{<br />
dwError = GetLastError();<br />
ErrorDescription(dwError);<br />
}<br />
OnBrefresh();<br />
<br />
CloseServiceHandle(hService);<br />
CloseServiceHandle(hSCM);<br />
} <br />
}
My question is, where is the bug?
|
|
|
|
|
I have a "user" type class with personal info in it which I wish to protect. I will use the Blowfish algorithm and I have two functions encrypt() and decrypt(). In my user class I used to serialize it to and from disk in plain text format using CArchive. What I can do is for each CString member of my user class I can encrypt each member before I serialize it or decrypt each member after I deserialize it.
I just want some opinion on what is the best way to do this. In some ways I think encrypting/decrypting each member (there are many members in the class) is not the best way. I wondered if I should encrypt/decrypt in one go in other words, when writing the file, I should write as plain text, then I should encrypt, or could I modify CArchive to do the encryption in a more logical manner?
Can anyone tell me how best to go about this because I want to not have lots of repetitive code to do the encryption and decryption.
|
|
|
|
|
I encrypt in memory then write to disk becuz if you write data to disk first then encrypt it, deleting your old file (unless you shred it first or encrypt over top original) it's then possible to undelete your original un-encrypted file. So I always encrypt in-memory before writting to disk.
Cheers
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
Good point
I have now written my encryption code into my user class where I now think it belongs. I just pass my key to the user class and let that do the worrying about encryption.
|
|
|
|
|
The application that I am working on has a view with base class CListView. When I click on an item in the list, I change the state mask.
i.e.
lvi.state = INDEXTOSTATEIMAGEMASK(n);
Then, I update the list.
I would like to scroll to the item in the list which I have just changed. I have tried GetScrollInfo and SetScrollInfo. This moves the scroll bar to the specified position but the list view does not scroll (remains at top).
How do I scroll the view with the scrollbar?
Any advise which can help me understand this method is greatly appreciated.
|
|
|
|
|
Incredibly, after several evenings bashing my head on this problem, I found the answer directly after submitting my question. I have found that I only needed to use the method EnsureVisible.
Thanks to anyone who took time to read my dumb question. Any further advise is certainly welcome.
|
|
|
|
|
I do this same thing all the time
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
What is the fasted way to swap bytes in a ushort/ulong?
For example:
0x1234 -> 0x3412
0x12345678 -> 0x78563412
unsigned short short_exch(const unsigned short a)
{
return (a << 8) + (a >> 8);
};
unsigned long long_exch(unsigned long a)
{
unsigned long t = a&0xff;
a >>= 8;
t <<= 8;
t += a&0xff;
a >>= 8;
t <<= 8;
t += a&0xff;
a >>= 8;
t <<= 8;
return t + a;
};
Jürgen Eidt
http://cpicture.de/en
|
|
|
|
|
Try a union :
<br />
typedef union<br />
{<br />
ULONG itemlong;<br />
UCHAR itemchar[4];<br />
} UnionLong;<br />
then you can swap the bytes through a temporary variable.
a two cent stamp short of going postal.
|
|
|
|
|
Didn't thought of a union
But even swapping with the xor trick I'm not sure how the compiler optimization would be. I guess looking at the asm code would make the final judgement.
Thanks.
Jürgen Eidt
http://cpicture.de/en
|
|
|
|
|
unsigned long Swap(unsigned long value)
{
return ((value & 0xFF000000) >> 24) |
(value & 0x00FF0000) >> 8) |
(value & 0x0000FF00) << 8) |
(value & 0x000000FF) << 24);
}
Software Zen: delete this;
|
|
|
|
|
|
You're welcome. If you make the function inline , the compiler will compile it in place without the function call overhead (I forgot to do that).
Software Zen: delete this;
|
|
|
|
|
Of course inline!
Actually you can remove the masking for the 24 bit shifts. For the inner two bytes I don't see an improvement.
Thanks Gary for the follow up
Jürgen Eidt
http://cpicture.de/en
|
|
|
|
|
I need help in .cpp and .h implementation code for the 8 bit binary addition.
The program has to handle additions of both positive and negative binary strings with the following assumptions:
The first string is stored using two's complement and the second using 8-bit bias notation. The result should be a bit string in two's complement (including a decimal interpretation of the result). I even have to keep track of overflow condition.
It would be great if you can send me the code.
|
|
|
|
|
I think you would probably learn much more if you were to do your own homework than if someone else were to do it for you.
a two cent stamp short of going postal.
|
|
|
|
|
Hello,
I have not done MFC programming for quite awhile and am now undertaking a (sort of) relearning process.
Could someone tell me if I can implement a certain process in InitInstance (derived from CWinThread) without freezing the OS, i.e. a drive parser which looks for certain files to analyse & update.
Also, if you are in possession of a good knowledge about Threads (specifically CWinThread) would you mind telling me a bit about how it works in a general way?
Thank you for taking the time.
David
dNimrod#X
________________________
|
|
|
|
|
dNimrod#X wrote:
Could someone tell me if I can implement a certain process in InitInstance (derived from CWinThread) without freezing the OS, i.e. a drive parser which looks for certain files to analyse & update.
I guess you can. As long as you provide a way to inform your application's user about what the hell is happening i.e. why is it taking too long. are you getting my point? (Ofcourse, I am talking about interactive applications)
Gurmeet S. Kochar
If you believe in God, it's because of the Devil
|
|
|
|
|
Gurmeet S. Kochar wrote:
I guess you can. As long as you provide a way to inform your application's user about what the hell is happening i.e. why is it taking too long. are you getting my point? (Ofcourse, I am talking about interactive applications)
Yes I understand your point but what I am not sure about is if the dialog box's controls will still be accessible while the disk drive parsing is running. I mean, the question now is whether or not the dialog box will not freeze (if the message proc will still handle messages from the dialog box) ?
Ravi Bhavnani wrote:
Yes. But you will probably want to create the file search and analysis as a separate thread.
Do I really have to?
Thanks a lot for your replies and for taking the time.
dNimrod#X
________________________
|
|
|
|
|
Yes. But you will probably want to create the file search and analysis as a separate thread.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
i have two questions:
1) how do i go about creating a gui for a dos (not dos-mode) application? ie. what program do i use to creat this?
2) if i don't want to make a gui then what do i need to make a command based application in dos? and are .exe and .com the same thing?
thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|