|
M. Dunn has the right response. If you are just assigning a simple string of characters to the CString object, using the assignment operator is the easiest. Employ the use of Format() only when variables/values need to be substituted.
|
|
|
|
|
Hello,
does anyone know how to customize the look of the CListCtrl RectTracker? I want it to look like the Windows XP Explorer RectTracker and still reuse a max of stuff already implemented in the standard RectTracker provided by CListCtrl (like dynamic selection and partial invalidates)?
Regards,
Nicolas
|
|
|
|
|
In MSDN I’ve found article Q179221 where it is described how to do it using Explorer Policies
(keys NoRun, NoFileUrl, NoDrives, etc under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer). But it is not prevent, for example, of viewing end executing files in the frame: .
Is anybody ever met with such a task?
|
|
|
|
|
>Is anybody ever met with such a task?
Yeah, pretty simple. Just embed webbrowser in your own application,
OnNavigate(Navigate2) check url and cancel navigation if it is local drive.
Brian
|
|
|
|
|
This one is probably asked before, I saw some solutions but none of them seem to work.
How do you make a text static transparent?
I've got this:
CStatic m_ctrlLabel;<br />
m_ctrlLabel.Create(_T("TEST"), WS_VISIBLE|WS_CHILD, CRect(0,0,32,16), pParent, 0);<br />
m_ctrlLabel.ModifyStyleEx(0,WS_EX_TRANSPARENT);
But this doesn't work. Did I forget something?
btw. I'm not planning to subclass the control.
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
Control with WS_EX_TRANSPARENT has the background of its parent. You probably put static control on i.e tab control which lies on dialog. But the parent of static control is still this dialog. To correct such situation override CDialog::OnCtlColor. Type ON_WM_CTLCOLOR() in MESSAGE_MAP. Then
change the background color of your static control as you wish (i.e set it as those tab control):
HBRUSH CTTSDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_STATIC && pWnd->GetDlgCtrlID() != IDC_DEFAULT_CHECK)
{
CWnd *TabCtrl = GetDlgItem(IDC_LANG_TAB);
CWnd *Ctrl = GetDlgItem(pWnd->GetDlgCtrlID());
if (Ctrl)
{
CRect Rect; Ctrl->GetWindowRect(&Rect);
TabCtrl->ScreenToClient(&Rect);
COLORREF Clr = TabCtrl->GetDC()->GetPixel(Rect.left-1, Rect.top-1);
DeleteObject(hbr);
hbr = CreateSolidBrush(Clr);
pDC->SetBkColor(Clr);
}
}
return hbr;
}
|
|
|
|
|
MSDN:
WS_EX_TRANSPARENT Specifies that a window created with this style is to be transparent. That is, any windows that are beneath the window are not obscured by the window. A window created with this style receives WM_PAINT messages only after all sibling windows beneath it have been updated.
In other words all WS_EX_TRANSPARENT does is changes the way WM_PAINT is sent. To make static transparent You need to override OnCtlColor and set correct dc mode.
HBRUSH CMyFormView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (m_nWhich==ID_MY_STATIC )
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
}
}
|
|
|
|
|
I would like to know if there is a way to disable the enter key from being used in my app. It seems that every time the enter key is pressed, it closes a dialog in my app.
Thank you.
Jimmy
Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
|
|
|
|
|
There are basically 2 ways to handle this.- Write a handler for OnOK() that doesn't do anything (i.e. just returns) and create another "OK" button (eg. with id
IDC_REAL_OK_BUTTON ) and write a handler for that, which simply calls CDialog::OnOK() .
- Override
PreTranslateMessage() and filter out the appropriate message - I think it's WM_CHAR but I could be wrong. This will force your user to click the OK button to end the dialog. /ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks Ravi,
I am still new to Programming, and what you said makes sense but is still foreign to me.
Can you tell me where I would find the PreTranslateMessage() function?
Perhaps you would be kind enough to point me to some example code or some steps to which i can get this accomplished.
Thanks you.
Jimmy
Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
|
|
|
|
|
|
Furthermore, override OnClose().
Kuphryn
|
|
|
|
|
Hi,
I have a single line edit box on a dialog. When the user finishes typing in the edit box and presses the Enter key I would like to receive notification so that I can do the required processing.
How do I get notified when the user presses the Enter key? Is my only option the PreTranslateMessage?
Thanks.
|
|
|
|
|
See my reply to the next (i.e. more recent) message in this forum.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi dear,
I created a thread.
But when I start the thread CPU load become 100%.
I use these code.
void CEventLine::BeginThread()<br />
{<br />
m_isRunning = TRUE;<br />
AfxBeginThread(ThreadStart,this,THREAD_PRIORITY_LOWEST);<br />
}<br />
<br />
UINT CEventLine::ThreadStart(LPVOID pParam)<br />
{<br />
CEventLine* pEventLine = (CEventLine*)pParam;<br />
if (pEventLine == NULL || !pEventLine->IsKindOf(RUNTIME_CLASS(CEventLine)))<br />
return 1;
<br />
while(m_isRunning == 1)<br />
pEventLine->Start();<br />
<br />
return 0;
}<br />
<br />
void CEventLine::Start()<br />
{<br />
}<br />
CEventLine is a CDialog based class.
Thank you in advance.
|
|
|
|
|
It's no great shock that the CPU load is 100%.
After all...
while (m_isRunning == 1)
pEventLine->Start ();
...
}
void CEventLine::Start ()
{
}
simply calls Start again and again and again... with no pause for "breath". It would be the same
if you put this code in your main thread. You have a few choices...
a) Put up with it. Assuming this is only for a brief duration.
b) Put up with it, but make it less of a nuisance. I've not used MFCs threads, and MFC is poor at sharing,
but you can lower thread priority to make other threads more responsice.
DWORD dwID;
hScanThread = ::CreateThread (NULL, 0, DoScan, this, CREATE_SUSPENDED, &dwID);
if (hScanThread == NULL)
{
DWORD dwError = ::GetLastError ();
} else
::SetThreadPriority (hScanThread, THREAD_PRIORITY_HIGHEST);
c) Put a delay (sleep) between each iteration of the loop. This would have to be short.
d) Some other tactic depending on the contents of CEventLine::Start () .
Iain.
|
|
|
|
|
Choice e) might be let the thread naturally relinquish the CPU by blocking on an I/O or message queue, for example. Depending on how often/long it blocks, this may be enough.
Brad
|
|
|
|
|
True, but then it may not respond to the "quit" flag.
Then again, waiting on multiple objects (the first of which is a KILL, DIE, DIE! event)
is the way I usually go. But with less dramatic variable names.
Iain
|
|
|
|
|
Sleep(0) is perfect here.
You can be nice to the system by simply using your time slice to make *one* check of the flag
and then turning over control to another thread.
Although typically I would argue against using a flag and using an appropriate synchronization
object instead.
|
|
|
|
|
Hi !
We just started to use WinCVS with Visual Studio 6 for our new project, but we don't have any experience with it. We made it work, but I would like to know if someone uses WinCVS as well.
What I'd like to know is what to do with the .obj files. When I update my project from the server, the .cpp and .h files are usually updated correctly, but the .obj, as binaries, are usually a mess, and I just have to rebuild all, which takes time.
How do you guys work ? Do you put your obj files into CVS ?
Thanks for sharing your experience !
Jerome
|
|
|
|
|
Why on earth would you put obj files in CVS?
Just put the stuff that isn't re-created automagically there.
(To add binaries you need to mark them as just that or else CVS will corrupt them).
|
|
|
|
|
Stefan Pedersen wrote:
Why on earth would you put obj files in CVS?
Well, when we first decided to use CVS, we didn't want to put obj files in it, but if we don't, each time I update my local project, I have to rebuild all, which takes a long time. How did you managed to solve this problem ?
Thanks for your answer !
Jerome
|
|
|
|
|
You shouldn't need to rebuild all.
Only the files needed should be rebuilt (you seldom update the whole project).
I would check the clock on all the computers used for devel and CVS.
Something seems a bit fishy...
|
|
|
|
|
Maybe this page can help you?
Info: (cvs) Binary howto
It talks about using the -kb option when adding a file to the repository.
|
|
|
|
|
Hello,
I know there is function that escapes an URL (for example transforms "bla bla" to "bla%20bla")...
What was its name?
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|