|
Easy on the caps lock .
WM_PAINT is sent to a window when the client area (i.e. the bit in the middle where your controls etc go) need to be repainted.
WM_NCPAINT is sent to a window when teh non-client (NC) area (e.g. the title-bar, and borders) need to be redrawn.
You can cause the OnPaint function to be called by invalidating part of the window (I believe, it may require slightly more than this, anyone?) - I believe the function you're looking for is CWnd::InvalidateRect().
HTH,
--
Andrew.
|
|
|
|
|
Andrew Peace wrote:
I believe, it may require slightly more than this, anyone?
Yes, you will need to call say UpdateWindow() .
I personnally like RedrawWindow() as you do not need to use Invalidate() or InvalidateRect() , the region is specified within the parameters to RedrawWindow()
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
wait a sec.....
what is the difference between Invalidate() and UpdateWindow()......arent they both used for repainting??
can u enlighten me on thiz plz!!!!!
thanx....for the prev answer!!!!!
|
|
|
|
|
Invalidate marks a region that it needs to be repainted but does not cause a WM_PAINT message to be sent.
On the next WM_PAINT message the region is repainted.
UpdateWindow will send the WM_PAINT message.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
easy on the caps....lol....ok....
thanx for ur reply.....
can u tell me how can i call the Onpaint() function of the dlg class from an another class say CMyClass??
thanx for ur help.....
|
|
|
|
|
Either call UpdateWindow() or RedrawWindow() from the CDialog based class.
or
Use SendMessage() to send a WM_PAINT message to the dialog window.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
just one more question.....;)
can u tell me how can i call the Onpaint() function of the dlg class from an another class say CMyClass??
right now i use the timer function which is defined in the dialog to update the dialog box......can u suggest an another method whereby which i am able to call the OnPaint() function of the dialog class from the CMyClass???
NOTE:actually the CMyClass being a derived calss ......i have put in message handlers such as 'mousemove()'...etc....and when such mouse action takes place......it is supposed to update the dialog box......
thanx a lot for ur prevoius replies.....
|
|
|
|
|
The easiest way to do this is to pass a pointer to the dialog into the CMyClass. We will call the dialog CMyDialog.
CMyClass header file
public:
void SetDialog(CMyDialog* pDialog);
<p></p>
private:
CMyDialog* m_pDialog;
CMyClass cpp file
void CMyClass::SetDialog(CMyDialog* pDialog)
{
m_pDialog = pDialog;
}
<p></p>
void CMyClass::SomeUpdateFunction
{
m_pDialog->Invalidate();
m_pDialog->UpdateWindow();
or
m_pDialog->SendMessage(WM_PAINT, NULL, NULL);
or
m_pDialog->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
}
Notice that I have given you 3 alternative ways to do the update in the update function.
I have made the assumption that Within the CMyDialog class you have defined the CMyClass as follows
CMyDialog header file
CMyClass m_MyClass;
CMyDialog cpp file
BOOL CMyDialog::OnInitDialog()
{
:
m_MyClass.SetDialog(this);
:
return TRUE;
}
Hope that this is clear
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
:-Dyes....thanx for the reply.....
u c to do this.....i have to include CMyDialog.h file in the CMyClass.h file.....
but the CMyClass.h is included in the CMyDialog.h file.....so what happens.....
i get errors.....something like....."';'is missing" and meany unresolved errors.....
statements that didnt have errors before.....
but i like the idea.....
getting the address thru pointers .....never struck me.....
so what i did next was the that all the variables that i needed from the CMyDialog class I had made pointers to get their address and gave to to the CMyClass(using the SetDialog(*var1,*var2,,,,)).....
then what i did is that i BitBlt it in the CMyClass itslf rather than doing it in the CMyDialog.....
funny.....i didnt get any errors or warningz.....but it didnt work.....i meant the windows error box opened up asking whether to debug or sen or not to send the error report.....
any ideas???
thanx a lot.....u helped me lot.....i owe u.....
|
|
|
|
|
I have overloaded the CTreeCtrl::OnCustomdraw ( NMHDR* pNMHDR, LRESULT* pResult )
Function and would like to make the item texts Bold.
Can I use the NMLVCUSTOMDRAW struct. I have tried looking in MSDN.
I successfully have changed the text color with the following code:
<br />
void CSimpleTreeCtrl::OnCustomdraw ( NMHDR* pNMHDR, LRESULT* pResult )<br />
{<br />
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );<br />
pLVCD->clrText = RGB( 210, 65, 20 );
}<br />
Any suggestion how to change the font… ?
_____________________________
...and justice for all
APe
|
|
|
|
|
You just need to select the font into the NMLVCUSTOMDRAW's dc.
You will need to create a member font variable that will be used throughout the life of the control.
NMTVCUSTOMDRAW* pTVCD = (NMTVCUSTOMDRAW*)pNMHDR;
*pResult = CDRF_DODEFAULT;<br>
switch( pTVCD->nmcd.dwDrawStage )
{
case CDDS_ITEMPREPAINT:
{
SelectObject(pTVCD->nmcd.hdc, (HFONT)(*m_pFont));
*pResult = CDRF_NEWFONT;
}
break;
default:
break;
}
I Dream of Absolute Zero
|
|
|
|
|
OK It worked... but...
When making a bold font the text became wider an the last letters in is missing in the text-area... Do you have any cure for that?
_____________________________
...and justice for all
APe
|
|
|
|
|
Hello!
I have tried to apply a style to a message box using a UINT which I then add flags to like:
MB_ICONINFORMATION
MB_ICONEXCLAMATION
MB_ICONQUESTION
MB_ICONSTOP
I also add the button types: MB_OK , MB_RETRYCANCEL , etc.
So I will pass a parameter in to set my style like this:
MB_OK | MB_ICONINFORMATION
I think this should work.
Next I wish to look at the uStyle variable and determine what flags are set in it.
if (uStyle & MB_ICONSTOP)
hIcon = LoadIcon(NULL, IDI_HAND);
else if (uStyle & MB_ICONEXCLAMATION)
hIcon = LoadIcon(NULL, IDI_EXCLAMATION);
else if (uStyle & MB_ICONINFORMATION)
hIcon = LoadIcon(NULL, IDI_INFORMATION);
else if (uStyle & MB_ICONQUESTION)
hIcon = LoadIcon(NULL, IDI_QUESTION);
This does not work like I think it would.
This is what the values are:
MB_ICONINFORMATION;
MB_ICONEXCLAMATION;
MB_ICONQUESTION;
MB_ICONSTOP;
Can someone tell me what I am doing wrong and if there is anywhere I can look to tell me how to work with bitwise flags?
|
|
|
|
|
You have your understanding of the values all wrong; the binary you show is not correct for the hex values. It doesn't make any difference though; your code wouldn't work anyway.
Simply you need to change your code:
if (uStyle & MB_ICONSTOP)
to
if ((uStyle & MB_ICONSTOP) == MB_ICONSTOP)
and similarly in all the other places.
The problem is that the MB_ values do not use mutually exclusive bits. For example, MB_ICONEXCLAMATION and MB_ICONQUESTION both have bit 5 set so (uStyle & MB_ICONQUESTION) will yield non-zero (true) for either.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
Phil J Pearson wrote:You have your understanding of the values all wrong
I thought this!
So 0x00000040L == 1000000 not 101000
I had converted decimal to binary instead of hex to binary
Phil J Pearson wrote:
The problem is that the MB_ values do not use mutually exclusive bits.
Yes I thought this was the problem but I did not think of what you suggested, to AND them and compare with the value I wanted!
Thank you
|
|
|
|
|
Hi
It seems like my exe prog. have a memory leak problem. The program read from the lpCmdLine, 6 different files, merges this to one output file and then close.
I close all handle before i Exit.Is there something i have to do, to free memory? I call the exe file 15 times per minute. By the way the program is programmed in Embedded C++, and runs on a CE panel.
Some code:
#include "stdafx.h"
#include "Afx.h"
#include "Winuser.h"
#include "stdlib.h"
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
DWORD dwBytesRead, dwBytesWritten, dwPos;
char buff[4096];
TCHAR* filnavn1;
TCHAR* filnavn2;
TCHAR* filnavn3;
TCHAR* filnavn4;
TCHAR* filnavn5;
TCHAR* filnavn6;
TCHAR* filnavnhtml;
DWORD dwBytesRead, dwBytesWritten, dwPos;
HANDLE hFile1, hFile2, hFile3, hFile4, hFile5, hFile6, hAppend;
hFile1 = CreateFile (filnavn1, // Open .txt
GENERIC_READ, // Open for reading
0, // Do not share
NULL, // No security
OPEN_EXISTING, // Existing file only
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No template file
//I open 6 files
hAppend = CreateFile (filnavnhtml, // Create output file.
GENERIC_WRITE, // Open for writing
0, // Do not share
NULL, // No security
CREATE_ALWAYS, // Open or create
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No template file
dwPos = SetFilePointer (hAppend, 0, NULL, FILE_END);
do
{
if (ReadFile (hFile1, buff, 4096, &dwBytesRead, NULL))
{
WriteFile (hAppend, buff, dwBytesRead,
&dwBytesWritten, NULL);
}
}
while (dwBytesRead == 4096);
// I do this with all 6 files
//close all files
CloseHandle (hAppend);
CloseHandle (hFile1);
Return 0;
}
Thanks
|
|
|
|
|
gunnar66 wrote:
It seems like my exe prog. have a memory leak problem.
How do you know this?
Are you allocating memory for filnavn1 and filnavnhtml ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi
In the CE panel the used memory is growing when my exe prog is running.
I am not allocating any memory for filnavn1 and filnavnhtml
|
|
|
|
|
gunnar66 wrote:
I am not allocating any memory for filnavn1 and filnavnhtml
They are declared as pointers. Shouldn't you be allocating memory for them like:
TCHAR *filnavn1 = new TCHAR[some_size];
...
delete [] filnavn1; Or since they are used for filename purposes, you could just use a stack-based buffer of size MAX_PATH like:
TCHAR filnavn1[MAX_PATH];
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
i m trying to convert bitstream file to .MPEG or .AVI ... how can i do that? anybody help me plz ...
pradeep
|
|
|
|
|
I coded a MFC DLL that acts itself as client for some COM server. When I use this MFC DLL within a
MFC application all is running fine. But when using the DLL from within an win32 (with MFC support) console application, I face the runtime error "CoInitialize not called". After that i added a "CoInitialized" call at the start of the win32 application. But then I face a memory access error.
-section of MFC DLL function to call
TaiPanClient* TaiPanClient::create(){
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
COleException *e = new COleException();
TaiPanClient *_client = NULL;
//do initialized ole support
if(!isOleInitialized){
if(!AfxOleInit()){
cerr << "[error] " << "OLE 2.0 Automation Initilization failed" << endl;
return _client;
}
isOleInitialized = true;
}
//check whether we can get an application handle
try{
ITaiPan *app = new ITaiPan();
if( app->CreateDispatch( APPLICATION_HANDLE ,e ) == TRUE ) {
_client = new TaiPanClient((void*) app);
} else {
cerr << "[error] " << "Cannot attach to COM Server, Version Independent Prog ID TaiPan.Anwendung" << endl;
throw e;
}
} catch(COleException *e){
char str[1000];
e->GetErrorMessage(&str[0], 1000);
cout << "exception thrown " << &str[0] <
|
|
|
|
|
I want to understand the knowledge of Encode amd Decode,
could you give me some?
Thanks !
|
|
|
|
|
Encode goes from A to B. Decode comes back.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
Encode, or encrypt, means to convert data or some physical quantity into a given format (e.g., ROT-13). Decode, or decrypt, means to convert code into ordinary language.
For example, before you send a password to someone via e-mail, you would first encrypt it so that it is not easily readable. When the recipient opens your e-mail, they would need to decrypt the password before being able to use it. If my password was saturday and I encrypted it using ROT-13, the result would be fngheqnl.
Make sense?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
How to implement a C++ application on my website?
|
|
|
|
|