|
soul_ripper wrote:
this message is not working
Define "not working."
soul_ripper wrote:
Call SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS, Null)
You're sending a message that sets the metrics associated with the nonclient area of nonminimized windows, yet those metrics are never supplied. Does that not raise any flags?
You need to declare a NONCLIENTMETRICS structure, fill in the relevant members, and pass that in as the fourth parameter.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Like this sampel ?
[code]
//// Simple Sub Call
void __declspec(dllexport) TestSubb
(int Message1, char Message2, char Message3, char Message4)
{
Message1, // handle of destination window
Message2, // message to send
Message3, // first message parameter
Message4; // second message parameter
::SendMessage (Message1, Message2, Message3, Message4);
return;
}
[/code]
i have this error :
[code]
C2664: 'SendMessageA' : cannot convert parameter 1 from 'int' to 'struct HWND__ *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
[/code]
Why ?
Jeroen
|
|
|
|
|
soul_ripper wrote:
::SendMessage (Message1, Message2, Message3, Message4);
You are callng SendMessage() wrong. Read here.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I posted a question the other day about using MFC's CListCtrl as a base. Someone told me to draw the control dynamically on my empty control and then relay the function calls to the CListCtrl object. This was a great idea, and exactly what I needed. But I don't know where to put the code to create the listview at. If I put the creation code in My Control's constructor, it compiles fine, but never actually draws it. I put the same code to create it in a dialog-based app and it draws just fine. I even tried a couple of other places in my Control's code, but it crashes on me when I try to actually use it (in VB). Can anyone tell me what's the problem? Thanks in advance
bdiamond
|
|
|
|
|
Do you handle WM_PAINT messages? Check if you should forward the message to CListCtrl.
...Plug & Pray...
|
|
|
|
|
thanks
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Hi,
I am trying to use GetSaveFileNamePreview to show a preview of the selected AVI movie. When I call GetSaveFileNamePreview I see the typical explorer-style dialog but no control to preview the movie. Is there something special that I need to add to make this happen?
Here is a code snippet:
OPENFILENAME ofn;
DWORD dwWinMajor;
dwWinMajor = (DWORD)(LOBYTE(LOWORD(::GetVersion())));
::ZeroMemory(&ofn, sizeof(OPENFILENAME));
TCHAR szFile[MAX_PATH];
TCHAR szFileTitle[MAX_PATH];
::ZeroMemory(&ofn, sizeof(ofn));
_tcscpy(szFile, this->m_sFileName);
if((BYTE)dwWinMajor >= 5)
{
/*Add 12 bytes to OPENFILENAME on Win2K or greater*/
ofn.lStructSize = sizeof(OPENFILENAMEEX);
}
else
{
ofn.lStructSize = sizeof(OPENFILENAME);
}
ofn.hwndOwner = ::GetActiveWindow();
ofn.lpstrFile = szFile;
ofn.lpstrFilter = TEXT("AVI Files (*.avi)\0*.avi\0");
ofn.nMaxFile = (DWORD)_tcsclen(szFile);
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.lpstrInitialDir = NULL;
ofn.lpstrDefExt = TEXT(".avi");
ofn.lpstrTitle = TEXT("Save AVI Movie As");
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_OVERWRITEPROMPT;
if(::GetSaveFileNamePreview(&ofn) == TRUE)
{
/*Do something here*/
}
Thanks for your help,
Andy
|
|
|
|
|
Hi,
I'm trying to implement double buffering in my MFC application, but keep running into a (to me) strange problem. I've read through the article "drawing speed in GDI+", and been trying to follow the code from step 2 in this article. My code (see below) compiles, but when I execute my app, I get the "standard" windows dialog, which asks if I want to send an error report, and forces me to terminate the application.
Please remember that I'm a newbie, there are certanly much bad code below, I'm just asking for the error ...
My view is derived frow CScrollView. Does this have anything to do with anything?
<br />
<br />
CRect rect;<br />
GetClientRect(&rect);<br />
int nWidth = rect.right - rect.left +1;<br />
int nHeight = rect.bottom - rect.top + 1;<br />
<br />
CClientDC ClientDC(this);<br />
Graphics graphics(ClientDC.m_hDC);
<br />
#ifdef _DEBUG<br />
#undef new<br />
Bitmap* bmp = new Bitmap(nWidth,nHeight);<br />
#define new DEBUG_NEW<br />
#else<br />
Bitmap* bmp = new Bitmap(nWidth,nHeight);<br />
#endif<br />
Graphics* graph = Graphics::FromImage(bmp);<br />
<br />
CRect area( 0, 0, 0, 0);<br />
<br />
area.SetRect( 8, 90, 814, 90);
DrawLine(&graphics, area, 1);<br />
<br />
<br />
Pen pen(Color(200,0,0, 50));<br />
for( int j=100; j<500;j = j + 5) {<br />
for (int i=100; i<500; i = i + 5) {<br />
area.SetRect( 110,110, j, i);<br />
<br />
DrawLine(&graphics, area, 1);<br />
<br />
}<br />
}<br />
<br />
graphics.DrawImage( bmp, 0,0, 600, 600);<br />
delete graph;<br />
delete bmp;<br />
<br />
This is my version of DrawLine
<br />
void CITPAXpertView::DrawLine(Graphics *pdc, CRect rect, int width)<br />
{<br />
CPoint where = GetDeviceScrollPosition();<br />
<br />
Pen penn(Color(0,0,0), REAL(width));<br />
<br />
pdc->DrawLine( &penn, rect.left - where.x, rect.top - where.y, rect.right - where.x, rect.bottom - where.y);<br />
}<br />
|
|
|
|
|
I try to reproduce your program. In MFC SDI application I added to following code to view OnDraw function:
void CGDITestView::OnDraw(CDC* pDC)
{
CGDITestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
CRect rect;
GetClientRect(&rect);
int nWidth = rect.right - rect.left +1;
int nHeight = rect.bottom - rect.top + 1;
CClientDC ClientDC(this);
// Graphics graphics(ClientDC.m_hDC); // GDI+ Stuff graph(ClientDC.m_hDC);
Graphics graphics(pDC->m_hDC); // GDI+ Stuff graph(ClientDC.m_hDC);
// Test for drawing with double buffering
// Bitmap* bmp = new Bitmap(nWidth,nHeight); and
// Bitmap* bmp(nWidth,nHeight); seems to give the same results...
#ifdef _DEBUG
#undef new
Bitmap* bmp = new Bitmap(nWidth,nHeight);
#define new DEBUG_NEW
#else
Bitmap* bmp = new Bitmap(nWidth,nHeight);
#endif
Graphics* graph = Graphics::FromImage(bmp);
CRect area( 0, 0, 0, 0);
// This works, no questions asked, but it's not double buffering
//area.SetRect( 8, 90, 814, 90); // Skillelinje som skiller elevdata fra resten av skjemaet
//DrawLine(&graphics, area, 1);
/* Test drawing to test double buffering */
// Takes about 10 seconds without double buffering
// Takes about xx seconds with double buffering
Pen pen(Color(200,0,0, 50));
for( int j=100; j<500;j = j + 5) {
for (int i=100; i<500; i = i + 5) {
area.SetRect( 110,110, j, i);
// This works.
//DrawLine(&graphics, area, 1);
// This line causes the crach, when commented out, the code does what it's supposed to do
graph->DrawLine(&pen, area.left, area.top, area.Width(), area.Height());
}
}
graphics.DrawImage( bmp, 0,0, 600, 600);
delete graph;
delete bmp;
/* End test drawing */
}
It works. From your post it is difficult to understand what happens. Please remove all lines which are not related to your problem, and post the whole function (including header).
>> I get the "standard" windows dialog, which asks if I want to send an error report.
To get more information run program in Debug congiguration, and use Go command instead of Run. In this case program breaks in Debugger and you can see what exactly happens.
|
|
|
|
|
<br />
void CITPAXpertView::OnDraw(CDC* )<br />
{<br />
CITPAXpertDoc* pDoc = GetDocument();<br />
ASSERT_VALID(pDoc);<br />
if (!pDoc)<br />
return;<br />
<br />
<br />
CRect rect;<br />
GetClientRect(&rect);<br />
int nWidth = rect.right - rect.left +1;<br />
int nHeight = rect.bottom - rect.top + 1;<br />
<br />
CClientDC ClientDC(this);<br />
Graphics graphics(ClientDC.m_hDC);
<br />
#ifdef _DEBUG<br />
#undef new<br />
Bitmap* bmp = new Bitmap(nWidth,nHeight);<br />
#define new DEBUG_NEW<br />
#else<br />
Bitmap* bmp = new Bitmap(nWidth,nHeight);<br />
#endif<br />
Graphics* graph = Graphics::FromImage(bmp);<br />
<br />
CRect area( 0, 0, 0, 0);<br />
<br />
<br />
Pen pen(Color(200,0,0, 50));<br />
for( int j=100; j<500;j = j + 5) {<br />
for (int i=100; i<500; i = i + 5) {<br />
area.SetRect( 110,110, j, i);<br />
}<br />
}<br />
graphics.DrawImage( bmp, 0,0, 600, 600);<br />
delete graph;<br />
delete bmp;<br />
<br />
}<br />
This is the function in question. As you can see, I've commented out both lines that draw in the view. If I use the first line, things work fine. If I use the second line, I get in trouble
The rest of the class is basically a standard CView class, except that I've made a few changes to change it to CScrollView. Things seem to be working fine, so I assume that I haven't missed anything, and the class is in fact a CScrollView class, but I might be wrong?
As in your test, the application is SDI.
Thanks, I really appreciate your efforts.
|
|
|
|
|
Please correct obvious error:
CClientDC ClientDC(this);
Graphics graphics(ClientDC.m_hDC);
replace with
Graphics graphics(pDC->m_hDC);
Uncomment pDC in the function header. I don't beleive this is a reason, but I want to be sure that all code is OK. If problem is not fixed, post here.
I want some other information: debug this function and be sure that after the lines:
Bitmap* bmp = new Bitmap(nWidth,nHeight);
Graphics* graph = Graphics::FromImage(bmp);
bmp and graph are not NULL.
|
|
|
|
|
Alex Farber wrote:
CClientDC ClientDC(this);
Graphics graphics(ClientDC.m_hDC);
replace with
Graphics graphics(pDC->m_hDC);
Ok, I've done this, and uncommented pDC in the header. The results are the same...
I sat a breakpoint at the line "CRect area(0,0,0,0);", and checked bmp and graph... I'm quite sure this is the problem, I just don't know what to do about it
bmp gave me 0x00000000.
graph gave me the status "0x00000000 {nativeGraphics=??? lastResult=??? }"
I might be misunderstanding these results, but I hope it's what you asked for. (Not quite used to using the debugger, you might say )
|
|
|
|
|
Bitmap is not created. Interesting, why. What are nWidth and nHeight values? Try this:
Bitmap* pMemBitmap = new Bitmap(nWidth, nHeight, PixelFormat24bppRGB );
|
|
|
|
|
nWidth are right-left+1 in the rect returned by GetClientRect, and the similar goes for nHeight.
Using another Pixel Format didn't help, unfortunately.
|
|
|
|
|
>> nWidth are right-left+1 in the rect returned by GetClientRect, and the similar goes for nHeight.
I know, I asked what are their values in debugger? 10, 100 etc.
|
|
|
|
|
Sorry, my bad
nHeight = 654
nWidth = 1023
However, VStudio marks these values in red. Any particular reason?
|
|
|
|
|
They are marked in red because they are used in current program line.
I really don't have idea what happens. The last thing I can suggest is to see the whole project. If you can make it available for download, post me link to it. Or you can e-mail it to me.
|
|
|
|
|
Yeah, "check"'s in the mail :P
|
|
|
|
|
Move GDI+ initialization code in InitInstance to the place before creating of main frame. Currently it is placed after creating and showing of main frame, and first time view is redrawn, GDI+ is not initialized.
By the way, I didn't know that CodeProject allows to post e-mail with attachments. Since you mahaged to do this, you get an answer immidiately.
|
|
|
|
|
Works, thanks!
About the e-mail: I don't quite understand. I simply found your e-mail from the mail I got with the alert connected to this thread, and sendt you a ordinary mail
Thanks for all help!
|
|
|
|
|
Hi,
I was hoping I could get you to look at another problem I've been having with this double buffering...
It's posted elsewhere on the forum: Thread.
Could you maybe take a look at it, and give it a shot?
|
|
|
|
|
Hi,
How could I get the begin and the end of the hibernate event (if exist) on WinXP ?
I have to know when the user start ("turn off" the machine) and finish ("turn on" the machine again) the hibernate process.
Thanks,
Cris.
|
|
|
|
|
You could try handling the WM_POWERBROADCAST message.
|
|
|
|
|
Hello,
Can anyone provide me some ideas or resources in order to read the .PSD file? I am more interest to know how can I read the layer information of in the .PSD file.
Thanks!
Nachi
|
|
|
|
|
Go here and search for the PSD format.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|