|
Unless you REALLY need to look exactly for "-help" I would recommend a case insensitive string comparison. Not all users rememebr you want all lower case for command line arguments, for example - see stricmp
|
|
|
|
|
Alright. That certainly is a good suggestion. Thanks.
I believe I will make that change. Thanks for taking the time to let me know about the stricmp() function.
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
|
|
|
|
|
how do i create a PE explorer or a resource hacker?
|
|
|
|
|
There is a very small-scale one on MSDN, and a much better one here at CP. Have you tried Googling?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi everyone!
I'm trying to send VK_RCONTROL to an application by unsing the SendInput method.
Does anyone know how to do this?
void sendChar(BYTE c){
INPUT input[2] = {0};
input[0].type = input[1].type = INPUT_KEYBOARD;
input[0].ki.wVk = input[1].ki.wVk = c;
input[1].ki.dwFlags = KEYEVENTF_KEYUP;
::SendInput(sizeof(input) / sizeof(INPUT), input, sizeof(INPUT));
}
//Doesn't work
sendChar(VK_RCONTROL);
|
|
|
|
|
Can you try it with the VK_CONTROL to see if it works?
I found this comment in WINUSER.H, which makes me suspicious that the VK_RCONTROL might not work ever.
* VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
* Used only as parameters to GetAsyncKeyState() and GetKeyState().
* No other API or message will distinguish left and right keys in this way.
|
|
|
|
|
Thanks for the response!
I've tried VK_CONTROL, but it will act as the left control button.
Since the program I'm trying to send right control to is making a destinction between right and left, there has to be a way to send right control. (read hack)
/Peter
|
|
|
|
|
This is what I got to work:
sendChar(VK_RCONTROL, 0x1D, TRUE);<br />
<br />
void sendChar(BYTE c, WORD wScanCode, BOOL bExtended)<br />
{<br />
<br />
INPUT input[2] = {0};<br />
<br />
input[0].type = INPUT_KEYBOARD;<br />
input[0].ki.wVk = c;<br />
input[0].ki.wScan = wScanCode;<br />
if( bExtended ){<br />
input[0].ki.dwFlags = KEYEVENTF_EXTENDEDKEY;<br />
}<br />
<br />
input[1].type = INPUT_KEYBOARD;<br />
input[1].ki.wVk = c;<br />
input[1].ki.wScan = wScanCode;<br />
input[1].ki.dwFlags = KEYEVENTF_KEYUP;<br />
if( bExtended ){<br />
input[1].ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;<br />
}<br />
<br />
UINT uCount = ::SendInput(sizeof(input) / sizeof(INPUT), input, sizeof(INPUT));<br />
<br />
}
Whether or not the scan code was sent, and with the virtual key always set to VK_RCONTROL, the 'virtual key' my test progrma always received in the WM_KEYDOWN and WM_KEYUP was always VK_CONTROL.
I tried leaving out the scan code (or setting it to zero) and without the 'proper' scan code, the key events the progrma receives look like a regular CONTROL key with the 'extended key' flag bit set. I am not sure that your program processing the input would interpret that as the 'right' control key, but you can test it. You might need to add the scan code, but be aware that the scan codes can vary by keyboard. As a result, you might need to provide a 'configuration utility' to allow user to enter the scan codes for the special 'extended' keys you want to send.
|
|
|
|
|
Cool!
It works flawlessly, I didn't even have to change the scan code!
Thank you very much!
/Peter
|
|
|
|
|
here is how I understand the job of this function :
Let's say I have an EditBox (which ID is IDC_MYEDIT),a pointer to that CEdit (called m_pMyEdit) and a CString object (called m_strEditText) associated to the control by DDX (DDX_Text (pDX, IDC_MYEDIT, m_strEditText); ).
When I call UpdateData(TRUE) , IDC_MYEDIT is filled with the content of m_strEditText.
When I call UpdateData(FALSE) , m_strEditText is affected with the content of IDC_MYEDIT.
until there, am I still right ?
Now, here is my problem:
<font color=#0000FF>void</font> CMyClass::OnEditMyEdit() {
UpdateData(); <font color=#008000>
<font color=#0000FF>int</font> iStartSel = m_strEditText.GetLength();
<font color=#008000>
m_strEditText = <font color=#008000></font>;
UpdateData(FALSE);
m_pMyEdit->SetSel(iStartSel, -1);
} This code is supposed to search for the string typed in the EditBox into a ComboBox, complete the string, then select its content that was added programatically (I try here - maybe you understood it - to make an auto-complete with a case sensitive behavior).
The problem is that, if I use UpdateData(FALSE), the completion is not what I expect.
However, if replace
UpdateData(FALSE); with
m_pMyEdit->SetWindowText(m_strEditText); , my function works exactly as I want of it...
Did I misunderstood how UpdateData() worked ?
Did anybody encountered such a problem, or a problem with This function ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
See here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
toxcct wrote:
When I call UpdateData(TRUE), IDC_MYEDIT is filled with the content of m_strEditText.
When I call UpdateData(FALSE), m_strEditText is affected with the content of IDC_MYEDIT.
No, that's backwards. Passing TRUE copies from the control to the variable. Your sample code is using the paramter correctly, however.
The first thing to check is that you call UpdateData(FALSE) in OnInitDialog() . You need to call that once before all other DDX operations. The wizard-generated code does this, so check that you didn't accidentally delete it.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Michael Dunn wrote:
so check that you didn't accidentally delete it.
First, i didn't delete anything from OnInitDialog() (and it is not the first time i program a dialog box), and moreover, the call of UpdateData() is made into CDialog::OnInitDialog() , not into mine...
secondly, my other handlers work well, and i just have this one that behaves strangely...
i really don't understand why, but i "very sure" that the problem comes from the call of that function...
... And as i don't want to mix the uses of UpdateDate() and SetWindowText()...
any tips ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hey,
I have a class (derived from CObject) containing variables (and functions). I put this class (Object) into a CObArray. Now I would create a copy of the class as a NEW Object (thus not only a copy of the pointer as with CObArray.copy).
Do I have to copy all Member of the class "by hand" or is there a more comfortable way.
Thanks in advance...
|
|
|
|
|
depends...
the objects, you copy them "by hand".
the pointers, you should allocate a new memory area to copy its content (otherwise, if you just copy the pointer, you will have 2 pointers - with so the same address inside - pointing to the same object). this will avoid modifying the same object when you think they have each theirs, and delete ing 2 times the same object.
That is for your own class members. For the base class (here, CObject), call its constructor before the instructions block (sorry, I lost the name of this place ) :
CMyClass::CMyClass(CMyClass& ref) : CObject() {
}
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi!
I wanna preserve "this" pointer's address to some member variable, so that, at some later stage, i can reuse this address.
If any one knows the solution (Visual C++'s reference), kindly inform me as soon as possible.
Thnx
Usman Arif
Usman Arif
|
|
|
|
|
I don't understand your question ?
this<code> is always available within the class.<br />
<br />
<br />
<pre>class MyClass;
class MyClass {
MyClass* m_pMyClass;
void DoSomething();
};
...
void MyClass::DoSomething()
{
m_pMyClass = this;
}<pre>
<hr><a href="http://www.thesorus.qc.ca">Maximilien Lincourt</a>
Your Head A Splode - Strong Bad</pre></pre>
|
|
|
|
|
You might also want to be careful that if you did store the address, you don't try to use it after the class is destroyed.
|
|
|
|
|
I have got a small problem with ActiveX control..When i place it inside activeX container, initially it sticks to the rectangle (previously in which ellipse is drawn by default). When i resize the drawing in onDraw(), it clips the outer parts and initially it displays the part in the default rectangle area whateva can come inside it. I need a tip to initialize the rectangular area with my own bounds .Please do reply, i am helpless in my final year project without getting to solve this problem , thanks.
|
|
|
|
|
Hi everyone outthere,
I have a regluar TTL Signal. Like this one:
Now i need to detect the distance between these two points:
This and This
\/ \/
----- ----- -----
| | | | | |
| | | | | |
--------| |---| |---| |---
Hope you understand what i mean ^^.
Here is a link to a drawing
http://www.cofan.co.kr/image/other/et05.gif
just look at the signal not at all the Data which stands there.
RedDragon2kx
|
|
|
|
|
not at all...
coy your scheme into a <pre></pre> block to let us see the spaces...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I need to get the time between
This This
\/ \/
|----| |----| |----|
| | | | | |
| | | | | |
-----| |----| |----| |----
Points. I hope it works now ^^
|
|
|
|
|
What are you trying to accomplish here? Is this a software project, or hardware? Do you have an input card that you're monitoring, or is this sampled data in a file?
"If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
|
|
|
|
|
It's a hardware device that I'm monitoring. It's a TTL Signal, I believe it's only produced by Transistors but I'm not sure. Sorry for my bad description.
|
|
|
|
|
Okay, that's clear. Now, what are you using to monitor it? Do you have a digital input card or analog? Are you digitizing samples into a file, or simply ones and zeroes? In either case the method is similar, though an analog sampling device takes a bit more work to decide when the signal state has changed.
Method 1:
Sample the signal at a fixed interval of time. How often depends on the accuracy of measurement required. Initialize a counter on the first falling edge, then increment it until the next falling edge is detected. Multiply the count by the time between samples.
Method 2:
As before, sample at regular intervals, depending on the accuracy needed. At the first falling edge, read the system clock and save the value. At the second, read the clock again, then calculate the difference between the two values.
Since it's not really clear yet what you are looking for, one efficient way to detect a state change - assuming you're looking at a stream of digital inputs, not digitized analog - is to XOR the current value with the previous value. If the result is true, and the current value is 0, you have just found a falling edge. If the result is true and the current value is 1, you've detected a rising edge. Anytime the result of the XOR is false, the values match and no state change has occurred.
Both methods will be somewhat unreliable under Windows, as you can't guarantee that some samples won't be missed or delayed because of other tasks grabbing the CPU just before a new sample is scheduled. This is an application where a hardware solution is easier and better to use. A simple gate circuit to enable or disable a fixed, accurate clock signal connected to a counter will do the trick. The only trouble with a hardware solution is that, while the actual measurement circuit is trivial, the interface required to make it readable by a PC involves a lot of overhead. Why not buy a device made for the purpose? Dataq (www.dataq.com[^]) makes a line of inexpensive modules which connect to a serial port and come with software to use them for various measurements of this sort.
Good luck!
"If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
|
|
|
|