|
#1 - clumsy, forcing an unneeded dependency for Foos on ClassA.
#2 - bad, semantically if not syntactically.
asincero wrote: Perhaps I should I break out the Foos typedef into it's own header (perhaps
the header file for class Foo?) and have both class_a.h and class_b.h
include that?
Yes.
Foo.h:
class Foo;
typedef std::vector< boost::shared_ptr<Foo> > VectorSharedPtrFoo;
class Foo { ... };
or,
class Foo {
typedef std::vector< boost::shared_ptr<Foo> > VectorSharedPtr;
};
I usually prefer the former.
In general, do not define a type in a class unless it is specific to that class.
... and do you _really_ want to return a vector from ClassA::makeFoos() ?
The newer compilers can try to optimize out the copy, but you're never sure.
Usually better to pass a non-const ref as an output parameter....cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Hi Members
I am try to hook keybord ON WINDOWS 7.I find some artical from codeguru.I have little dot.When i write some word on notepad and office document then it's working.But when i going on Internet explorer or mozila then working something wrong.
[]
In mozila alwalys call double processkey(..)
In Internet explorer when i type on address bar the function call
processkey(..) but when i type something on web page the function not call.
If any thing wrong then sorry .I have no clue how to solve that problem.Please help me.
|
|
|
|
|
Is Keyboard hook only for Notepad.exe ( check somewhere in DllMain()) or its global hook?modified on Friday, February 19, 2010 5:57 PM
|
|
|
|
|
SIR thanks for responce.
What i do in DllMain?
#include "stdafx.h"
#include "keydll3.h"
#pragma data_seg(".HOOKDATA")//Shared data among all instances.
HHOOK hook = NULL;
HWND hwnd = NULL;
#pragma data_seg()
#pragma comment(linker, "/SECTION:.HOOKDATA,RWS")//linker directive
HINSTANCE hinstance = NULL;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
hinstance = (HINSTANCE)hModule;
hook = NULL;
return TRUE;
}
KEYDLL3_API void installhook(HWND h)
{
hook = NULL;
hwnd = h;
hook = SetWindowsHookEx(WH_KEYBOARD,hookproc,hinstance,NULL);
if(hook==NULL)
MessageBox(NULL,"Unable to install hook","Error!",MB_OK);
}
KEYDLL3_API void removehook()
{
UnhookWindowsHookEx(hook);
}
KEYDLL3_API LRESULT CALLBACK hookproc(int ncode,WPARAM wparam,LPARAM lparam)
{
if(ncode>=0)
{
if((lparam & 0x80000000) == 0x00000000)
{
hwnd = FindWindow("#32770","Keylogger Exe");
PostMessage(hwnd,WM_USER+755,wparam,lparam);
}
}
return ( CallNextHookEx(hook,ncode,wparam,lparam) );
}
or give me some other dll web address.
Please help me....modified on Saturday, February 20, 2010 2:49 PM
|
|
|
|
|
Take a look at this link for reference Hooks and DLLs[^]
Looks to me that WM_USER+755 message may be already register with one of plug in of the browswer. the above link shows how to create unique message.
HTH
|
|
|
|
|
Hello all,
I am trying to rotate a bitmap at integer multiples of 90° and looking for a fast and efficient way to do it. I have looked through lots of code over the net involving multiplications and going through each pixel which I dont prefer. I also came accross a way where you can use worldtransform, but MSDN states that even at 90° rotation the image will have shear effects.
My bitmap bitdepth is 8bits (grayscale) and in my application as soon as I get a frame (which is in bytes[8bit image]) from framegrabber, I memcpy it to pDIBSecBits of the bitmap and I bitblt it to the display. Now I need to rotate the image at 90°cw to compensate the rotation of an hardware in our system. I tried worldtransform, but it didnt work for me except showing a black display.
here is how I am using it for 90°cw rotation..
CDC *dc = Display->GetDC();
HGDIOBJ holdbm;
holdbm = memDC.SelectObject(hbm);
float cosine = (float)cos((-90.*22.)/(7.*180.));
float sine = (float)sin((-90.*22.)/(7.*180.));
XFORM xform;
xform.eM11 = cosine;
xform.eM12 = -sine;
xform.eM21 = sine;
xform.eM22 = cosine;
xform.eDx = (float)-bmi->bmiHeader.biWidth;
xform.eDy = (float)-bmi->bmiHeader.biHeight;
SetGraphicsMode(dc->m_hDC, GM_ADVANCED);
SetWorldTransform( dc->m_hDC, &xform );
dc->BitBlt(0,0,bmi->bmiHeader.biWidth, bmi->bmiHeader.biHeight, &memDC, 0, 0, SRCCOPY );
memDC.SelectObject(holdbm);
ReleaseDC(dc);
Could someone help me to figure out an efficient/fast way to do this rotation?
thanks in advance,PKNT
|
|
|
|
|
if you have the bytes, just allocate a new buffer and copy the bytes into the new buffer, with row and columns transposed.
|
|
|
|
|
You seem on the right track and I've done this in the past. Looking back at my code I see that in my code I wrote a description of what I was trying to do which I'll put below to save rewriting in the hope that the explanation may help you.I haven't put my whole function below, I've left out the part that finds the size of the new bitmap from the size of the old but maybe the part I've put will help.
The diagram is a bit out due to tabbing size but looked fine in Visual Studio and I'm sure you an get the idea.
HRESULT ClassName::GetRotatedBitmapNT(const CBitmap* pcbmBitmap, CBitmap* &pcbmRotated, float radians )
{
and the code:
HBITMAP hbmOldSource = (HBITMAP)::SelectObject( hSourceDC, hBitmap );
HBITMAP hbmOldDest = (HBITMAP)::SelectObject( hDestDC, hbmResult );
HBRUSH hbrBack = CreateSolidBrush( clrBack );
HBRUSH hbrOld = (HBRUSH)::SelectObject( hDestDC, hbrBack );
PatBlt(hDestDC, 0, 0, (int)newwidth, (int)newheight, PATCOPY );
::DeleteObject( ::SelectObject( hDestDC, hbrOld ) );
BOOL bRet;
POINT OldSourceOrg;
POINT OldDestOrg;
bRet = OffsetWindowOrgEx(hDestDC,(int)xmin, (int)ymin, &OldDestOrg);
float C = (float)cos(radians);
float S = (float)sin(radians);
float T11 = C;
float T12 = S;
float T13 = 0;
float T21 = -S;
float T22 = C;
float T23 = 0;
SetGraphicsMode(hDestDC, GM_ADVANCED);
XFORM xform;
xform.eM11 = T11;
xform.eM12 = T12;
xform.eM21 = T21;
xform.eM22 = T22;
xform.eDx = T13;
xform.eDy = T23;
SetWorldTransform( hDestDC, &xform );
BitBlt(hDestDC,0,0,bm.bmWidth, bm.bmHeight, hSourceDC, 0, 0, SRCCOPY );
bRet = OffsetWindowOrgEx(hSourceDC,OldSourceOrg.x, OldSourceOrg.y, NULL);
::SelectObject( hSourceDC, hbmOldSource );
::SelectObject( hDestDC, hbmOldDest );
pcbmRotated = new CBitmap();
pcbmRotated->Attach(hbmResult);
SetCursor(OldCursor);
return S_OK;
|
|
|
|
|
5 for the diagram. That's above and beyond the call of duty. Steve
|
|
|
|
|
Thanks Jonathan, it helped me to understand the usage of worldtransform clearly and I can see the difference in the way I am trying to use vs the way you described and your way is working flawlessly. PKNT
|
|
|
|
|
|
Hi all,
We know that Windows "Open With" dialog box shows a complete list of installed applications that can open a file of some format. I want the same list of applications.
I could not find anyway by which I could use and customize the "Open With" dialog box of Windows. But please note that I don't want the list of every executable that is shown by "Add/Remove Program".
Is there a way to get the list of applications that can open file of some format (as shown by "Open With" dialog box of windows.)?
I can code in both C++ and C# but preferably C#.
Thanks and Regards
Aseem
|
|
|
|
|
|
Have a think about file associations, and then where windows stores information.
I bet you could work it out for yourself in a few minutes. Morality is indistinguishable from social proscription
|
|
|
|
|
Aseem Sharma wrote: We know that Windows "Open With" dialog box shows a complete list of installed applications that can open a file of some format. I want the same list of applications.
Try the HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts registry key."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi,
Please let me know ;
Is subclass and drived class are same?
|
|
|
|
|
|
ok then what is difference between subclass and ownerdarw
|
|
|
|
|
maybe a precision, subclassing was mostly used in Win32 to help ownerdraw a control, but with MFC you can either subclass a control or derive from a control.
you csn subclass a control without having the need to ownerdraw it (for example change the behaviour without changing the look).
(I'm probably wrong, but ...) You need to subclass (or derive) to be able to Ownerdraw a control.
M.Watched code never compiles.
|
|
|
|
|
To subclass a window means to add the ability to intercept windows messages for a standard window or control and add some custom behaviour to it. Ownerdrawing is a facility provided by certain controls where the control itself calls back to a user function which performs the actual paint functionality. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
|
how to Arrange/sort rectangle control buttons according to size or name in a dialog based application please help me I have 10 buttons created dynamically in a dailog with different sizes.how to arrange them according to the sizes and according to name.When application is running
It is needed to create buttons dynamically.
-- Modified Friday, February 19, 2010 5:58 AM
|
|
|
|
|
Do you really need to create controls dynamically?!
However, take a look at MoveWindow()[^], SetWindowPos()[^], etc., to move your controls at runtime.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Hi All,
I have developed one Add ons for Internet explorer. Now I want to add Publisher name for add ones. When you will click on Tools->manage Add ons on IE, You will see list of publisher name like Google , yahoo for there ad ons.I want to add such publisher name for add ons.Is it related to code signing of application? plz send me some hint....
Thanks
abm
|
|
|
|
|
|