|
Only Days??
Most Software takes Months, (at least) so get used to it and don't give up after days. Hint: In future: Start Earlier.
Success
Bram van Kampen
|
|
|
|
|
who can tell me write a resource dll
e.g : include dialogbox,button and message loop
thanks
|
|
|
|
|
1/ Try posting a new question - you've only asked one person by replying to his post, and he might not care or know.
2/ Trying going to google, and search for "resource only dll" - there are several useful looking hits on the first page.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Bram van Kampen
|
|
|
|
|
Hello,
I am writing a program which can get the user-defind message from the specific program.
After the program get the message, the program will do post-processing.
If I do all action in MainFrame, the program can work. (I experimented this by pop-up a message window)
But if I want the message can be delivered to the document object from MainFrame,
then do post-processing in the document object, the program would fail.
The program would hang there and no response for any action. (Ex : close the program)
And at that time, the program which send the message even doesn't launch...
I have no idea to solve this problem. Does anyone can help me ?
My environment : Vista SP1, Visual Studio 2005 SP1, Platform SDK 2003 SP1
The MFC/SDI application is created by the wizard. I don't change the default class name.
Below is my code of MainFrm.h :
#pragma once
#include "LToolDoc.h"
#define MYWM_NOTIFYICON (WM_USER+2)
class CMainFrame : public CFrameWnd
{
protected:
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
public:
public:
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
DECLARE_MESSAGE_MAP()
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
};
and my part code of MainFrm.cpp is
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
CWnd* pWnd = AfxGetMainWnd();
if(pWnd == NULL)
return FALSE;
ASSERT_VALID(pWnd);
ASSERT_KINDOF(CFrameWnd, pWnd);
CFrameWnd* pMainFrame = static_cast<cframewnd*>(pWnd);
CFrameWnd *pActiveFrame = pMainFrame->GetActiveFrame();
if(pActiveFrame == NULL)
return FALSE;
CLToolDoc *pDoc = (CLToolDoc *)pActiveFrame->GetActiveDocument();
pDoc->TranslateMessage(pMsg);
return TRUE;
}
and the TranslateMessage() in LToolDoc is
void CLToolDoc::TranslateMessage(MSG* pMsg)
{
if(pMsg->message == USER_DEFINED_MESSAGE_1){
else if(pMsg->message == USER_DEFINED_MESSAGE_2){
else if(pMsg->message == USER_DEFINED_MESSAGE_3){
else{}
}
Thanks a lot !!!
|
|
|
|
|
What happens to all the messages that are not USER_DEFINED_MESSAGE_x?
Why use PreTranslateMessage() when MFC provides message handling for you?
It looks to me like you mark every message handled (by returning TRUE from
PreTranslateMessage() so all the system messages don't get handled.
You should return TRUE only if CLToolDoc::TranslateMessage() handles the message,
otherwise return CFrameWnd::PreTranslateMessage(pMsg).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for reply.
After reading your reply message, I modified the code.
Let the only USER_DEFINED_MESSAGE pass to CLToolDoc::TranslateMessage().
Now it can work. Thank you very much !!!
But the number of USER_DEFINED_MESSAGE in the program are so many (almost 300).
If the value of USER_DEFINED_MESSAGE are as the same as the system message (I think this condition might happen, I doesn't check the USER_DEFINED_MESSAGE totally), my program still hang there, right ?
Is the only way to solve above potential problem by making each USER_DEFINED_MESSAGE unique ?
Or another suggestion ? Thanks.
|
|
|
|
|
oppstp wrote: Is the only way to solve above potential problem by making each USER_DEFINED_MESSAGE unique ?
YES! They MUST be unique.
See WM_APP[^] for what values are safe to use.
You can also use RegisterWindowMessage()[^] if you need messages unique system-wide.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for the reply.
I will check the USER_DEFINED_MESSAGE totally and redefine them if need
|
|
|
|
|
if(SaferGetLevelInformation(s, SaferObjectAllIdentificationGuids, lpQueryBuffer, dwInBufferSize, lpdwOutBufferSize) == TRUE)
{
SaferCloseLevel(s);
}
else
{
printf("Error Code::%d\n",GetLastError());
}
The Above function fails and returns an error code:: 122(i.e The data area passed to a system call is too small.)!!!
can anybody suggest me where i am wrong!!
Thankx!!!
|
|
|
|
|
Hi,
Try to increase the size of the buffer(3rd parameter).
Also confirm this size greater than or equal to returned buffer size in last parameter "lpdwOutBufferSize".
The error you mentioned seems generally "buffer parameter was too small".
Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
Thankx suman !
I already increased the buffersize 50 times more .....but i got the same result
|
|
|
|
|
Aabid wrote: can anybody suggest me where i am wrong!!
How about showing the definition and initialization of lpQueryBuffer , dwInBufferSize , and lpdwOutBufferSize .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You must've hit the Post button two seconds before me!
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
SAFER_LEVEL_HANDLE s;
TCHAR lpQueryBuffer[MAX_PATH * 10] = "";
DWORD dwInBufferSize = sizeof(lpQueryBuffer);
LPDWORD lpdwOutBufferSize = &dwInBufferSize;
if(SaferGetLevelInformation(s, SaferObjectSingleIdentification, lpQueryBuffer, dwInBufferSize, lpdwOutBufferSize) == TRUE)
{
SaferCloseLevel(s);
}
else
{
printf("Error Code::%d\n",GetLastError());
}
|
|
|
|
|
Have you tried using a different address for lpdwOutBufferSize ? Having it use the same address as dwInBufferSize seems odd.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
As noted, don't have lpdwOutBufferSize point to your dwInBufferSize variable.
Also, since you have lpQueryBuffer defined as a TCHAR, you should use
TCHAR lpQueryBuffer[MAX_PATH * 10] = _T("");
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
It would help if you show how you declare, define, and initialize your lpQueryBuffer, dwInBufferSize, and lpdwOutBufferSize.
When you changed the size of the lpQueryBuffer, did you also note that change by changing the dwInBufferSize value?
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
I am trying to create a grayscale version of an icon. I have extracted the icon and have an HICON but how would I create a grayscale version? I have been trying to figure it out and it seems I need to create an HDC and draw the icon into that but I am new to graphics and am a bit lost...
|
|
|
|
|
hIconGrey = ::CopyImage( hIcon, IMAGE_ICON, 32, 32, LR_MONOCHROME );
too easy too find it
Greetings from Germany
|
|
|
|
|
Thanks for the reply but I have tried that and the image comes out just black and white, I need grayscale so the image looks like the original but no colour. Is there a way I can do that using that function?
|
|
|
|
|
You need to convert RGB values to grayscale values.
The typically formula used is
BYTE 8bitGrayscaleValue = (0.30 * RedByte) + (0.59 * GreenByte) + (0.11 * BlueByte)
or the integer (no floating point) version:
BYTE 8bitGrayscaleValue = (BYTE)((((int)RedByte * 30) + ((int)GreenByte * 59) + ((int)BlueByte * 11)) / 100);
You could create a 24bpp DIB section the dimensions of the icon, select it
into a memory DC, and draw the icon on the memory DC. Then using the pointer
to the DIBSection's pixel bits, iterate through the RGB pixel values, converting
each to grayscale.
That's the easiest way I can think of to access the pixel data of an icon.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Also, this may help:
CreateGrayscaleIcon[^]
The use of GetPixel() and SetPixel() are way slower than accessing pixel data directly as I proposed
in my previous post, if that's an issue.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
im trying to implement this example (http://www.codeproject.com/KB/openGL/GLBase.aspx) into my own little app.
cause i want to learn opengl,c++ & oop.
my german compiler (VC++ 2008 Express Edition) tells me there is in an error in the code.
basicly it sais 'int' cannot be converted to VSYNC, converting into an enumeration requires an explicit typecasting.
code:
in misc.h:
...
typedef enum tagVSYNC
{
VSync_Default = 0x0001,
VSync_On = 0x0002,
VSync_Off = 0x0003
} VSYNC, *PVSYNC;
typedef struct
{
VSYNC Status;
HWND hWnd;
HDC hDC;
BYTE nBPP;
BYTE nRefresh;
bool bFullscreen;
bool bZoomed;
} RENDERARGS, *PRENDERARGS;
...
in WinMain.cpp:
...
RENDERARGS Args={0}; <-this is the line the compiler complains about
...
can someone please help me?
modified on Wednesday, July 2, 2008 11:55 AM
|
|
|
|
|
testcrap wrote: RENDERARGS Args={0};
This is used to initialize the elements of an array. RENDERARGS isn't an array
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|