|
Bogdan Rechi wrote:
len(obj) returns 0,
You are supposed to use LenB instaed of Len for binary data.
|
|
|
|
|
Hi...
I want to insert text between 2 others lines in a text file.
Do I have to recreate this file or not???
Thanks in advance...
Hello World!!!
from Raphaël
|
|
|
|
|
The only way (to the best of my knowledge) is to create a new temporary file with the updated contents and then replacing the old file with this. Writing to a preexisting file works in an overwriting manner, rather than inserting extra space.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I tried the following:
void CMainFrame::OnChecking()
{
CMenu* mmenu = GetMenu();
mmenu->ModifyMenu(ID_CHECKING, MF_BYCOMMAND,ID_CHECKING, " Selection");
Invalidate();
This does change the title to "selection" but only after the second click. The old caption is still visible beneath the new one which looks like its on a button of its own placed over the old button. Please advise.
Thanks,
ns
|
|
|
|
|
Call function DrawMenuBar.
|
|
|
|
|
That was superb! I didnt know it existed! I really appreciate your help. MAny thanks!
ns
|
|
|
|
|
I have developed MFC based MDI application using VC++ 6.0. The application can open multiple documents using the File->Open menu option. Once there are many documents open, it is quite time consuming to close each of the documents one by one. For this reason I would be interested in providing a menu option under Windows popup menu i.e. Windows->CloseAll, that will help the application to close all the child windows at one shot. As an example the VC++ IDE can be referred, that provides this option. Can someone help me find a solution for doing this.
Thanks/Regards,
|
|
|
|
|
This thread discusses a similar problem, namely that of minimizing all child windows. I guess you can use the technique described there to your purposes.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
There is another easy way of doing this by writing the message handler in the CMainFrame class. The code is as follows...
void CMainFrame::OnWindowCloseall()
{
CMDIChildWnd* child = NULL;
while((child = MDIGetActive())!=NULL)
{
if (child)
child->MDIDestroy();
}
}
This will be completely MFC based.
Thanks/Regards,
|
|
|
|
|
I'm working on an application which has a CWnd descended window called CAnimateWnd.
CAnimateWnd uses SetWindowRgn(hClipRgn, TRUE) to change the shape of the window frequently. It then uses SetWindowPos() to change the location of the window.
Calling SetWindowRgn() with the second param (bRedraw) TRUE causes the window to be redrawn. Changing the position of the window with SetWindowPos() or MoveWindow() causes the window to be redrawn. However, since the new shape of the window may look wrong until the window is in its new position, I want the window to be redrawn only once.
If I call SetWindowRgn() with bRedraw as FALSE, the area beneath the window is filled back under the assumption of the new region shape rather than the old, leaving bits of the previous view behind.
Is there a way to set the window region and change the position in the same instant?
|
|
|
|
|
Hide the window before setting the new region and show it back after repositioning it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That works but it also makes the window flicker. Is there any other way to do it?
|
|
|
|
|
Well, I haven't tried this, but it might help reduce the flickering. Before repositioning the window, save its original surrounding rectangle with GetWindowRect . After repositiong, invalidate the desktop window with InvalidateRect using the rectangle previously saved.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That'sa good idea. I tried it but it didn't seem to have any effect at all. Maybe I'm doing it wrong. Do you see any obvious problems with this code?
<br />
void CAnimateWnd::ChangeAppearanceAndPosition(HRGN hNewRgn, int iPosX, int iPosY)<br />
{<br />
CRect oldRect;<br />
GetWindowRect(&oldRect);<br />
<br />
SetWindowRgn(hNewRgn, FALSE);
SetWindowPos(&wndTopMost, iPosX, iPosY, 100, 100, SWP_NOACTIVATE);<br />
<br />
::InvalidateRect( GetDesktopWindow()->GetSafeHwnd(), &oldRect, TRUE);<br />
}<br />
|
|
|
|
|
The code seems OK to me There are a couple of things you might want to try:- Do a
ScreenToClient of the rectangle for the desktop window prior to using it in InvalidateRect .
- Force the repainting of the desktop window with
UpdateWindow after invalidating. Other than these, I cannot come out with any other possible reason for this failing.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I tried each of those but there was no change. My guess is that, since I did not repaint during my SetWindowRgn() call, the desktop thinks it is intended to leave the bits of previous regions behind.
If I have to I can live with the flicker but I'd much rather have a perfectly smooth animation display.
|
|
|
|
|
What about this?
void CAnimateWnd::ChangeAppearanceAndPosition(HRGN hNewRgn, int iPosX, int iPosY)
{
CRgn oldRgn;
oldRgn.CreateRectRgn(0,0,0,0);
GetWindowRgn(oldRgn);
SetWindowRgn(hNewRgn, FALSE);
GetDesktopWindow()->InvalidateRect(&oldRgn);
SetWindowPos(&wndTopMost, iPosX, iPosY, 100, 100, SWP_NOACTIVATE);
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Ah, you mean InvalidateRgn(), right? Hrmm... still no visible effect. I wonder if we're misinterpreting the expected behavior for the Desktop Window. Maybe it doesn't know how to update but, rather, is simply storing an image of the desktop in its current state, in which case that current state would include the broken bits of previous animation frames.
|
|
|
|
|
Ummm. One more try:
void CAnimateWnd::ChangeAppearanceAndPosition(HRGN hNewRgn, int iPosX, int iPosY)
{
CRgn oldRgn;
oldRgn.CreateRectRgn(0,0,0,0);
GetWindowRgn(oldRgn);
SetWindowRgn(hNewRgn, FALSE);
InvalidateRect(&oldRgn);
SetWindowPos(&wndTopMost, iPosX, iPosY, 100, 100, SWP_NOACTIVATE);
} Would you care to tell me the result now?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Same as before. No visible change.
|
|
|
|
|
I found a solution. For the curious, I will post it here:
The main problem is that the window needs to change its HRGN shape and its position at the same time. Since the new shape will not be correct until the window is in the new position, I needed the window to redrawn only when both the new HRGN and the new position have been set but I still needed to restore the background in areas of the old shape which were not part of the new shape.
<br />
void CAnimateWnd::UpdateRgnAndPos(HRGN hNewRgn, int iPosX, int iPosY)<br />
{<br />
HRGN hOldRgn = CreateRectRgn(0, 0, 0, 0);
GetWindowRgn(hOldRgn);<br />
<br />
HRGN hOffRgn = CreateRectRgn(0, 0, 0, 0);
CombineRgn(hOffRgn, hNewRgn, NULL, RGN_COPY);
OffsetRgn(hOffRgn, iPosX - m_iOldPosX, iPosY - m_iOldPosY);
<br />
HRGN hCombinedRgn = CreateRectRgn(0, 0, 0, 0);
CombineRgn(hCombineRgn, hOffRgn, hOldRgn, RGN_OR);
<br />
SetWindowRgn(hCombinedRgn, FALSE);
<br />
SetWindowPos(iPosX, iPosY, 100, 100, SWP_NOACTIVATE);
<br />
SetWindowRgn(hNewRgn, TRUE);
<br />
Invalidate(TRUE);
<br />
m_iOldPosX = iPosX;
m_iOldPosY = iPosY;<br />
}<br />
|
|
|
|
|
Maybe you could uses 2 windows. You set the shape on the new window, show it (above the old), hide the old.
Or uses layered windows (see SetLayeredWindowAttributes) if you are using Windows 2000 or Windows XP. This allows to create transparent and semi-transparent windows.
Philippe Mori
|
|
|
|
|
Hello,
I have problem with a CListCtrl. As you know, pushing up/bottom arrow allow you to move up and down through the elements of your list (it's builtin). Everything was perfect since yesterday
I noticed that the arrows didn't respond. A message (WM_KEYDOWN) seems to be blocked by something but i can't put the finger on it. Mouse events work perfectly.
I derived a class from CListCtrl and i put it in a form derived from CFormView. As i said,all was working perfectly two days ago. The problem seems to be simple, i do not use special or custom code to process messages. I think i respect the way to implement controls using MFC.
Any tips to locate simply (with VC debugger) where the problem is?
Thank u!
Fred
C++/MFC/SQL Developer.
|
|
|
|
|
I'm not sure what differences you have between now and two days ago, but it sounds like you're being bitten by IsDialogMessage. Certain keystrokes are trapped by the system and treated as dialog navigation keys, rather than being sent to the control. Besides direction keys, this also includes things like Tab. Try adding a handler for WM_GETDLGCODE to your control. Return DLGC_WANTARROWS.
Scot Brennecke
Software Developer
VC++ MVP
|
|
|
|
|
Thank you,
I try immediately.
Fred
|
|
|
|
|