|
Hello,
have someone any Idea how to spy mousebutton clicks (No, not the normal buttons, one of the extended buttons, my mouse have 7 of them) with LibUsb http://libusb-win32.sourceforge.net/ , maybe with some example code snippets ?
I have only found:
-some Linux code for the "kernel"
-some Dos/command line based apps.
But i found no trick to use it in a windows application, neither it do nothing or the mouse "hang" because all the data are not pass through the mouse driver.
regards
Peter
|
|
|
|
|
--------------------------------------------------------------------------------
Hi!
I'm doing an application where I have to place wrapping text inside boxes.
It's an MFC single document view.
The problem starts when I zoom out or in:
CSize size = pDC->GetTextExtent(str);
size.cx will have different values depending on the zoom level.
I've read the documentation and GetTextExtent() it's suppose to work on Logical units, so I don't understand what is going on.
That's a big problem because I do the wrapping myself (i have rotated text) and the wrapping changes when zooming.
Help please!!! I've been working on this 3 days now!!
|
|
|
|
|
what do u mean zoom in/out?
e.g. original font height is 8, when zoon in as 50%, u set font height as 4?
|
|
|
|
|
includeh10 wrote: e.g. original font height is 8, when zoon in as 50%, u set font height as 4?
When you zoom in, fonts get bigger. So if you zoomed in by 50%, the font size would be 12. If you zoomed in by 100%, the font size would be 16.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
No. What I meant is that for a fixed fontsize, I get different results depending on the Viewport size.
CreateFont();
pDC->SelectObject(&m_Font);
CSize StrSize = pDC->GetTextExtent("helloamigo") ;
If I do this on MapMode MM_ANISOTROPIC, when I zoom in and out, changing the SetViewportExt I got different StrSize values.
Funny thing is that according to the documentation GetTextExtent should return values in logical units... but it seems to change depending on DC mapping mode.
That makes the wrapping to change depending on zoom values.
|
|
|
|
|
I solution I have found:
When creating the font with CreateFont use a NEGATIVE size (nHeight).
"< 0 The font mapper transforms this value into device units and matches its absolute value against the character height of the available fonts. "
I'm still having problems but I think they are less obvious now.
|
|
|
|
|
I want to limit print contents (bitmaps, texts and lines) inside a rectangle, any parts of print contents out of the rectagle will not be printed.
the function SelectClipRgn(...) works fine for screen DC, but doesn't work for print DC in MM_LOENGLISH mode.
ant suggestion to help?
|
|
|
|
|
The last time I worked with printing stuff, the first thing I did was look at the MFC code that's used for standard apps in OnPreparePrinting, etc. (You can find out which MFC source code files to look at by stepping into these functions in your debugger and simply noting which files they are.)
I think you'll find a fair amount of useful example code there. Take a look at what they're doing for the print preview stuff as well.
|
|
|
|
|
|
I have a DLL decalred as follows:
#ifdef DLLDIR_EX<br />
#define DLLDIR __declspec(dllexport)<br />
#else<br />
#define DLLDIR __declspec(dllimport)<br />
#endif<br />
<br />
extern "C"<br />
{<br />
<br />
int DLLDIR DLLFunc2(int);<br />
void DLLDIR DrawEllipse(CRect, CDC*);<br />
<br />
};<br />
<br />
extern int DLLDIR DLLArg;<br />
<br />
class DLLDIR DLLClass<br />
{<br />
<br />
public:<br />
DLLClass();<br />
~DLLClass();<br />
<br />
int Add(int, int);<br />
int Sub(int, int);<br />
int Identify(void);<br />
<br />
<br />
int Arg;<br />
<br />
};
I can access my DLL functions using LoadLibrary and GetProcAddress but how would I gain access to the DLL class using the same procedure?
Thanks.
|
|
|
|
|
You can't. You need to use implicit linking if you want to import classes (that is, you need to link to the library which is associated with the dll and not using LoadLibrary).
|
|
|
|
|
hey fellow cpians,
I am using std::ofstream to write data to a log file.. What i would like to do is monitor the size of the file and when it reaches a certain size close the file and reopen another one with an appropriate time stamp
i have a localised function which writes to the file. The name of the funcion is writeToLog( std::string s) . Every time the function is called with a new string i would like to check the size of the file before writing the string out. if the file size is 2Mb then i would close the file and reopen a new file with a new name.
My problem, however is that i do not know how to check the size of the open file using STL.
can anyone help.
thankyou.
|
|
|
|
|
flippydeflippydebop wrote: My problem, however is that i do not know how to check the size of the open file using STL.
Use seekg(0, ios::end) followed by tellg() .
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
If you use standard I/O, fseek() and ftell() can help. Check this out.
Best,
Jun
|
|
|
|
|
Jun Du wrote: If you use standard I/O, fseek() and ftell() can help.
Which is not part of STL.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thanks guys for your prompt replies...
cheers
|
|
|
|
|
hi everybody.
i am writing a list like control for a big app.
an it is done using oop.i have created a window which creates buttons.the buttons are created while watching it using spy.but they are not visible.PLEASE HELP ME!and tell me what i haven't done.here is some parts of code:
void ECMLMItem::Create(int i,CWnd *pParent,CRect rect,CRect RcList)
{
CWnd::Create(0,"ECMLMItem",WS_BORDER|WS_VISIBLE|WS_CLIPCHILDREN,rect,pParent,LISTITEM+counter,0);
counter++;
obj[i] = new ECMLMObjects();
obj[i]->create(i,this,rect,RcList);
}
void ECMLMItem::CreateObject(CWnd *pParent,int i)
{
if(i<10)
{
rect.left=RcList.left+12;
rect.top=RcList.top+20*i+1;
rect.right=RcList.right-12;
rect.bottom=rect.top+20;
ECMLMItem::Create(i,pParent,rect,RcList);
}
}
void ECMLMObjects::create(int i,CWnd *pParent,CRect rect,CRect RcList)
{
int w;
w=RcList.Width()-20;
rect.left=RcList.left+12;
rect.top=RcList.top+20*i+5;
rect.right=rect.left+w*3/15-2;
rect.bottom=rect.top+20;
btn[i].Create("",WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,rect,pParent,Button+i);
rect.left=RcList.left+w*3/15+15;
rect.top=RcList.top+20*i+5;
rect.right=rect.left+w*4/15-4;
rect.bottom=rect.top+20;
edt[i].Create(WS_VISIBLE|WS_CHILD,rect,pParent,editbox+i);
rect.left=RcList.left+w*7/15+15;
rect.top=RcList.top+20*i+5;
rect.right=RcList.right-12;
rect.bottom=rect.top+20;
name[i].Create("Hello",WS_VISIBLE,rect,pParent,statictext+i);
}
Sepehr_vision@yahoo.com
|
|
|
|
|
sepehr_vision wrote: and tell me what i haven't done
People here probably only can tell what have been done wrong (if you are lucky). Post specific questions. More specific the question, easier for you to get an answer.
Best,
Jun
|
|
|
|
|
sepehr_vision wrote: ECMLMObjects::create(int i,CWnd *pParent,CRect rect,CRect RcList)
reading this long code oh no no
but if you are creating a child in above given line
then please add WS_CHILD style at
name[i].Create("Hello"/*name*/,WS_VISIBLE|WS_CHILD,rect,pParent,statictext+i);
Tanvon
the brain behind ...
I Blog here
|
|
|
|
|
hi,
when I put this
Cstring rvalue
switch (rvalue)
{
case "0": AfxMessageBox("Communication error");
break;
case "Z":AfxMessageBox("Sucess");
break;
default : AfxMessageBox("rien");}
an error message is shown:
the expression associate to case is not a constant
how can i make it constant
|
|
|
|
|
That's not the way to work with string. You should do something like that:
if (rvalue == "0")
AfxMessageBox("Communication error");
else if (rvalue == "1")
AfxMessageBox("Sucess");
else
AfxMessageBox("rien");
Note that you can do something like rvalue == "1" only because CString overloaded the operator ==.
|
|
|
|
|
thanks a lot it is running !
|
|
|
|
|
zizzzz wrote: switch (rvalue)
u cannot specify a cstring variable in the switch condition. but u can do like this
switch(rvalue[0])// this will conside only the first character in the variable rvalue
{
case "0": AfxMessageBox("Communication error");
break;
case "Z":AfxMessageBox("Sucess");
break;
default : AfxMessageBox("rien");}
}
nave
|
|
|
|
|
Naveen R wrote: switch(rvalue[0])// this will conside only the first character in the variable rvalue
{
case "0": AfxMessageBox("Communication error");
break;
case "Z":AfxMessageBox("Sucess");
break;
default : AfxMessageBox("rien");}
}
I think you meant:
switch(rvalue[0])
{
case '0': AfxMessageBox("Communication error");
break;
case 'Z':AfxMessageBox("Sucess");
break;
default : AfxMessageBox("rien");}
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
ya..
thanks for pointing...
nave
|
|
|
|