|
Well, to tell you the truth, I am just a novice myself. I just did these thing recently so I know about them...If you do not need the text resource anymore then you should call FreeResource. My book says that even if you don't call FreeResource then it will be freed when the program terminates but I think that it's always a good idea to get rid of them when you are done with them. I think you also found a memory leak in my program since I was loading the resource every time I started the dialog and wasn't freeing it so thanks! About the the handle of the instance, there are many ways. What I use a global HINSTANCE hInst for example. In WinMain I set hInst = hInstance but you must set the global handle hInst to hInstance before CreateWindow in WinMain or else it won't work. I also found that out a couple of weeks ago. Other ways are in WM_CREATE you can declare a local HINSTANCE hInst and set it to hInst = ((LPCREATESTRUCT) lParam)->hInstance. Yet another way is GetWindowLong(hwnd, GWL_HINSTANCE). This also straight out of Charles Petzold's Programming Windows, in my opinion a book that everyone should have. Taught me everything I know! Good luck with your program.
|
|
|
|
|
Thanks a lot !
All this will help me a lot. In my former Jo I had that Petzold book, I think it's quite quite good ( I used it when MFC was not so good and I had to do some API stuff ), but in my current job I don't have it what a pity !
Thanks for the info, greetings
Braulio
|
|
|
|
|
Hi,
I have written this code to paint the background while resizing.
BOOL FrameWnd::OnEraseBkgnd(CDC* pDC)
{
CRect the_clientRect;
GetClientRect(&the_clientRect);
BITMAP the_bmp;
GetObject(the_bkgnd,sizeof(the_bmp),&the_bmp);
HDC hMemdc=CreateCompatibleDC(pDC->m_hDC);
if(hMemdc)
{
HBITMAP hOldBmp=(HBITMAP)SelectObject(hMemdc,the_bkgnd);
if(hOldBmp)
{
StretchBlt(pDC->m_hDC,0,0,the_clientRect.Width(),the_clientRect.Height(),hMemdc,0,0,the_bmp.bmWidth,the_bmp.bmHeight,SRCCOPY);
SelectObject(hMemdc,hOldBmp);
DeleteDC(hMemdc);
DeleteObject(hOldBmp);
return TRUE;
}
else
DeleteDC(hMemdc);
}
return TRue;
}
It works fine.But it flickers a lot.
Is there anyway to stop this flickering?
Regards,
Neha
|
|
|
|
|
|
Thanks for the link. That's a really good, succinct explanation; much better than any of the others I've found.
Software Zen: delete this;
|
|
|
|
|
|
Disable repainting while resizing.;)
Try this @ home. (B&B)
|
|
|
|
|
Could you tell me how to do this, I assume you are talking about situation where you only see the border of the window being moved and once you resized the window is painted again. This I would also like to do, plus, the same thing for moving a window, just the outline of it, then redraw.
|
|
|
|
|
You must proper handle the messages. For instance while resizing disable background painting. ( a Flag, reset after END resizing)
Read the posting and link above from "Rickard Andersson"
Try this @ home. (B&B)
|
|
|
|
|
I tried all of the above yet with no luck. Should I be disabling the background painting in the WM_PAINT message of WM_SIZE? If so what is the code for this? Maybe some code helps:
Here's my paint message:
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rectClient);
// Set Text Attributes
SetTextColor(hdc, RGB(0, 0, 225));
SetBkMode(hdc, TRANSPARENT);
SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
// Draw the Text
DrawText(hdc, szHeading, strlen(szHeading), &rectClient, DT_TOP |
DT_CENTER);
// Draw Horizontal Line
MoveToEx(hdc, 0, 35, NULL);
LineTo(hdc, rectClient.right, 35);
// Draw Vertical Line
MoveToEx(hdc, rectClient.right / 2, 35, NULL);
LineTo(hdc, rectClient.right / 2, rectClient.bottom - 100);
MoveToEx(hdc, 0, rectClient.bottom - 100, NULL);
LineTo(hdc, rectClient.right, rectClient.bottom - 100);
EndPaint(hwnd, &ps);
return 0;
And here is my sizing and colorlistbox message
case WM_SIZE:
cxClient = LOWORD(lParam);
cyClient = HIWORD(lParam);
MoveWindow(hwndLocalList, 5, 70, (cxClient / 2) - 10, cyClient - 165, FALSE);
MoveWindow(hwndHostList, (cxClient / 2) + 5, 70, (cxClient / 2) - 10,
cyClient - 165, FALSE);
return 0;
case WM_CTLCOLORLISTBOX:
SetTextColor( (HDC) wParam, RGB(255, 255, 255));
SetBkColor( (HDC) wParam, crBlue);
SelectObject( (HDC) wParam, GetStockObject(SYSTEM_FIXED_FONT));
return (LRESULT) hBlueBrush;
their wndclass.style is CS_VREDRAW | CS_HDREDRAW
Do you see what is wrong with the code?
|
|
|
|
|
WH_JOURNALRECORD and WH_JOURNALPLAYBACK
I try to use SetWindowsHookEx() and use two Hook type
WH_JOURNALRECORD and WH_JOURNALPLAYBACK to make
a capture and playback mechanism.
while on WH_JOURNALRECORD ,I store every messages that
the hookproc received,
and On WH_JOURNALPLAYBACK
I feed the messages I stored previously.
It seems works now,but still have some problems
while playback those messages.
1. it has TIME DELAY phenomena.
2. it has some messages lost phenomena.
the lost messages seems depends on system loading..
sometimes won't lost,but some times do if repeat playback
those messages recorded only once.
could someone have been done works like I do..??
any comment will be appreciate..
|
|
|
|
|
I have a dialog window with a CWebBrowser2 control on it, which I use to display a simple HTML report and allow it to be printed. I want the fact it is a web browser control to be transparent to the user, and therefore want to stop the IE menu from appearing when they right click on the control. Does anyone know where I can find code or an explaination on how to do this? I don't have much experience with ActiveX controls, and don't understand the explaination given to someone a while back.
|
|
|
|
|
there is an interface you can use IDocHostUIHandler
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
I am still a bit confused, I tried the following code:
CMyDialog::OnInitDialog()
{
...
DOCHOSTUIINFO *pInfo;
IDocHostUIHandler::GetHostInfo(pInfo);
pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU;
...
Am I using IDocHostUIHandler incorrectly? And I don't understand why I am getting undeclared variable errors?
|
|
|
|
|
|
Hi,
In my main application, i've created a thread which must send a message to a Document. Is this possible???
The ::Postmessage(...) work to send a message to a View (the first argument is a handle HWND)...
For the moment I send a message from this thread to the View and that work:
POSITION pos = GetFirstViewPosition();
HWND MyHwnd = (HWND) GetNextView(pos)->GetSafeHwnd();
DWORD error_flag = GetImage(m_pChannel, m_pImage, idcam);
::PostMessage(MyHwnd, WM_DISPLAYERRORMESSAGE, 0, (LPARAM) error_flag);
I want to send a message to the Document to simulate the use of a menu (e.i. "Stop" with the ID = ID_ACQUISITION_STOP)... How to do that...
Thanks in advance.
Hello World!!!
from Raphaël
|
|
|
|
|
Raphaël Kindt wrote:
Is this possible???
It's possible for WM_COMMAND , through the main frame. I have tried for user defined messages and it didn't work.
Anyway, i think the best method is the one you are currently using; it's strange to send messages to documents.
rechi
|
|
|
|
|
Hello everyone,
I am writing a server using winsock overlapped IO functions(WSASend, TransmitFile, and etc). I am wondering what situations will cause those operations exit without sending all packets.
Is is necessary to check the return value whenever an overlapped operation is completed to verify whether the those functions complete sending all data?
And where can I find some sample codes for server-side overlapped io operations?
thanks very much!
Kerry Chou
|
|
|
|
|
When the peer closes the socket prematurely; when a network error occurs; etc etc
#include <beer.h>
|
|
|
|
|
Hi!
I'm using owner draw buttons, and i have the need of making them disabled in some situations, i have this function:
void CMyButton::Activa(CWnd *pWnd, BOOL bEnable)
{
int iCtrl=0;
CString sTexto;
pWnd->EnableWindow(bEnable);
m_ToolTip.DelTool(pWnd, 0);
iCtrl=pWnd->GetDlgCtrlID();
pWnd->GetWindowText(sTexto);
}
This is called by the form class where the button is.
With pWnd i would also like to call its LPDRAWITEMSTRUCT, so i can call
void CMyButton::DrawButton(int nIDCtl, LPDRAWITEMSTRUCT pDI, CString sTexto)
and redesing the button for that situation, i'm not sure if this is the best solution for the propose but its the only i know!
Thank you for your time!
rui
|
|
|
|
|
How can i assign a value to the LPDRAWITEMSTRUCT struct parameters?
I tried :
void CMyButton::Activa(CWnd *pWnd, BOOL bEnable)
{
CRect rc;
pDIS->itemAction = ODA_DRAWENTIRE; <-error
pDIS->hwndItem = pWnd->GetSafeHwnd(); <-error
pDIS->hDC = (HDC)pWnd->GetDC(); <-error
pWnd->GetWindowRect(rc);
pDIS->rcItem = rc; <-error
CString sTexto;
//desactiva a o botao e os seus tooltips
pWnd->EnableWindow(bEnable);
m_ToolTip.DelTool(pWnd, 0);
//vai buscar ourtros dados do botao
iCtrl=pWnd->GetDlgCtrlID();
pWnd->GetWindowText(sTexto);
//passa o estado do botao para uma member variavel
bDisabled=bEnable;
DrawButton(iCtrl, pDIS, sTexto);
}
having
BOOL bDisabled;
int iCtrl;
LPDRAWITEMSTRUCT pDIS;
as member variables
Thank you
|
|
|
|
|
I am trying to create a pen in the following code:
LOGBRUSH logbr;
logbr.lbStyle = BS_SOLID;
logbr.lbColor = RGB(0, 0, 0);
logbr.lbHatch = 0;
if (MyPen.GetSafeHandle() == NULL)
MyPen.CreatePen(PS_COSMETIC|PS_ALTERNATE, 1, &logbr);
CreatePen fails in Win98 and succeeds in other platforms. Does anyone know what is wrong in my code? I need your help.
Thank You
|
|
|
|
|
It seems that W98 is not supporting this feature. Step in the CreatPen call and you will see it.
You should find another soultion for W98 machines.;)
Try this @ home. (B&B)
|
|
|
|
|
Hello!
I don't find a way to dock a bar on the bottom of the frame, above the statusbar.
I'd appriciate your help.
Guy.
|
|
|
|
|
Have you try this ?
In the OnCreate of the MainFrame:
if(!m_MyBar.Create(...)){
return -1; // fail to create
}
m_MyBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_MyLogBar, AFX_IDW_DOCKBAR_BOTTOM);
HTH,
A rock pile ceases to be a rock pile the moment a single man contemplates it, bearing within him the image of a Cathedral[^].
Antoine de Saint-Exupery (1900-1944)
|
|
|
|
|