|
Now i am programming an IME for Khmer letter. that application send the VK_BACK to erase a letter befor display an onother letter.
UINT scanBack;
scanBack = MapVirtualKey(VK_BACK, 0);
scanBack =(scanBack << 16) + 1;
PostMessage(GetFocus(), WM_CHAR, VK_BACK, scanBack);
PostMessage(GetFocus(), WM_CHAR, VK_BACK, scanBack);
PostMessage(GetFocus(), WM_CHAR, 0x17A4, 0);
the above code is just a part of condition i implemented to send keystroke to any window with keyboard focus.
some applications could be process well. but some allicaions could not be process.
please let's me know as you could do.
thank.
Nam
|
|
|
|
|
|
SendInput is a better option than Keybd_event, since keybd_event is now superceded with SendInput from Vista versions, microsoft recommends to use SendInput. So i prefer you to use SendInput to aviod porting issues.
Величие не Бога может быть недооценена.
|
|
|
|
|
|
Applications may handle key strokes differently. You may press back space manually and use spy++ to see the list of messages posted to the app window. After that, try sending the same sequence to the window.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
..using VB6, i have data saved in a column of an excel file that am trying to extract. the code i have written returns only zeroes, cant figure out what the problem...any suggestion would be appreciated!
#include "stdafx.h"
#include "stdio.h"
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
_variant_t raw_data[10];
Excel::_ApplicationPtr pApplication;
HRESULT hr = S_OK;
OleInitialize(NULL);
if ( FAILED( hr=pApplication.CreateInstance ("Excel.Application") ))
{
return 1;
}
_variant_t varOption( (long) DISP_E_PARAMNOTFOUND, VT_ERROR );
Excel::_WorkbookPtr pBook;
pBook = pApplication->Workbooks->Open("C:\\Myexcel",varOption, varOption, varOption, varOption,varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption );
Excel::_WorksheetPtr pSheet = pBook->Sheets->Item[(long) 1]; // grabs first worksheet
Excel::RangePtr pRange = pSheet->GetRange( _bstr_t( "B2"), _bstr_t("B2")); //loads column headers
int iColumn = 2;
_variant_t vItem = pRange->Item[(long) 1][(long) iColumn ];
_bstr_t bstrText( vItem );
// Load the rows
pRange = pSheet->GetRange( _bstr_t("B2"), _bstr_t("B12") );
for ( int iRow = 1;iRow < 10; ++iRow )
{
_variant_t vItem = pRange->Item[(long) iRow ][ (long) iColumn];
_bstr_t bstrText( vItem );
raw_data[iRow] = vItem;
cout << (long) raw_data[iRow];
}
// Don't save any inadvertant changes to the .xls file.
pBook->Close( VARIANT_FALSE );
// Need to quit, otherwise Excel remains active and locks the .xls file.
pApplication->Quit( );
return 0;
}
|
|
|
|
|
Whether this line is returning zero?
pBook = pApplication->Workbooks->Open("C:\\Myexcel",varOption, varOption, varOption, varOption,varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption );
Величие не Бога может быть недооценена.
|
|
|
|
|
The line is not, i put in a check to ensure that it wasnt null
|
|
|
|
|
i think the problem relies here
variant_t vItem = pRange->Item[(long) 1][(long) iColumn ];
_bstr_t bstrText( vItem );
Item property on Excel::Range returns another Excel::Range. So try 'Text 'property on the returned Range, as below..
_variant_t vItem = pRange->Item[(long)iRow][(long)iColumn];
Excel::RangePtr pSelRange = vItem.pdispVal;
_variant_t vItemText = pSelRange->Text();
cout<<vItemText.bstrVal;
|
|
|
|
|
I tried that line but i get error on the
Excel::RangePtr pSelRange = vItem.pdispVal; //new Range
am fairly new to C++, is there any kind of header that needs to be added in
other to execute that line?
the error is : error C2064: term does not evaluate to a function
|
|
|
|
|
which compiler do you use? Can't you attach the returned IDispatch* value (vItem.pdispVal) to new RangePtr object? I mean, isn't there any function some thing like pSelRange->AttachDispatch(vItem.pdispVal) ..?
|
|
|
|
|
Thanks all, i was able to discover what the problem was, i was setting icolumn to 2 instead of 1.............
|
|
|
|
|
buki86 wrote: _variant_t raw_data[10];
Shouldn't this be 11 ?
buki86 wrote: _variant_t vItem = pRange->Item[(long) 1][(long) iColumn ];
Since the range is only one cell, both the row and column will be 1 .
buki86 wrote: pRange = pSheet->GetRange( _bstr_t("B2"), _bstr_t("B12") );
for ( int iRow = 1;iRow < 10; ++iRow )
The range you are defining has 11 rows. The loop will run 9 times. Is that intentional?
Try something like:
for (int iRow = 0; iRow < 11; ++iRow)
{
_variant_t vItem = pRange.GetItem(COleVariant(iRow + 1L), COleVariant(1L));
_bstr_t bstrText(vItem);
raw_data[iRow] = vItem;
cout << (long) raw_data[iRow];
}
"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
|
|
|
|
|
how do i declare COleVariant? my compiler sees it as an undeclared
identifier....
|
|
|
|
|
It's in afxdisp.h .
"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 guys i would like to know how to do this i want to make my editing CEdit control know if it lost focus by a mouse click a keyboard hit, a popup window, etc
Thx
|
|
|
|
|
i don't think that's possible. any window can grab focus any time it wants, just by calling SetFocus, and it doesn't need to tell anyone why.
|
|
|
|
|
Your CEdit will receive a WM_KILLFOCUS ,
and you could implement a reaction for the message...
virtual void BeHappy() = 0;
|
|
|
|
|
Ok guys thanks i will have to do something else for this requirement.
|
|
|
|
|
Hi,
I am trying to follow some assembler code
in my program However it would be nice
if the C/C++ source statements will laid
out before the generated assembler code
I guess the compiler optimizes the code
and moves things around
would using the above #pragma get me
code where I code see what assembler code
is generated by the C/C+ source
|
|
|
|
|
Hi,
Yes the #pragma optimize directive can be used to disable compiler optimizations around a particular portion of code. You will also need to use the /FAs compiler switch to see both source and assembly.
/FA, /Fa (Listing File)[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Or you could just use the debug version of the compiled code? That would be just as valid as turning off optimisations selectively…
Why are you looking at the assembly language, BTW? If it's to debug a problem, then you have to look at the optimised code, painful as it might be...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
I just like to look at the paramters and return
code ax register etc optimized code is to difficult
|
|
|
|
|
ForNow wrote: However it would be nice
if the C/C++ source statements will laid
out before the generated assembler code
Such as what the /E and /P compiler switches do?
"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
|
|
|
|
|
Sorry for delayed response
was observing passover
/P and /E are for pre-processor
|
|
|
|