Board index » cppbuilder » How should I move the cursor??
Oleg
CBuilder Developer |
How should I move the cursor??2006-10-18 07:48:04 PM cppbuilder68 We use Borland Developer Studio 2006 C++ Builder. In our program we use TStringGrid to display data. BiDiMode = bdRightToLeft, Options>>goEditing. We need to move the cursor ourselves using WindowProc. When we used C++ Builder 5, it worked perfectly. In BDS 2006 the cursor moves as if BiDiMode = bdLeftToRight while SelectCell is marked properly. In order to check, please, build a project and copy to unit: //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { StringGrid1 = new TStringGrid(this); StringGrid1->Parent = this; StringGrid1->BiDiMode = bdRightToLeft; StringGrid1->Align = alClient; StringGrid1->Options << goTabs; gridOrigProc = StringGrid1->WindowProc; StringGrid1->WindowProc = gridWindowProc; } //--------------------------------------------------------------------------- void __fastcall TForm1::gridWindowProc(TMessage &Message) { int x, y, ACol, ARow; if(Message.Msg == WM_LBUTTONDOWN || Message.Msg == WM_LBUTTONDBLCLK) { x = Message.LParamLo; y = Message.LParamHi; StringGrid1->MouseToCell(x, y, ACol, ARow); StringGrid1->Row = ARow; StringGrid1->Col = ACol; TRect ARect = StringGrid1->CellRect(ACol, ARow); CaretSetPosAndShow(ARect.Right - 5, ARect.Top); return; } gridOrigProc(Message); if(Message.Msg == WM_KEYDOWN && (int) Message.WParam == VK_TAB) { TGridRect AGridRect = StringGrid1->Selection; ACol = AGridRect.Left; ARow = AGridRect.Top; TRect ARect = StringGrid1->CellRect(ACol, ARow); CaretSetPosAndShow(ARect.Right - 5, ARect.Top); return; } } //--------------------------------------------------------------------------- void TForm1::CaretSetPosAndShow(int x, int y) { bool ret; try { HideCaret(StringGrid1->Handle); DestroyCaret(); CreateCaret(StringGrid1->Handle, NULL, 4, 15); ret = SetCaretPos(x, y); ShowCaret(StringGrid1->Handle); } catch(...) {; } } //--------------------------------------------------------------------------- to header file //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components private: // User declarations public: // User declarations TStringGrid *StringGrid1; __fastcall TForm1(TComponent* Owner); virtual void __fastcall gridWindowProc(TMessage &); void __fastcall (__closure *gridOrigProc)(TMessage &Message); void CaretSetPosAndShow(int x, int y); }; Click on a Cell and keep moving while pressing TAB. We will be greatfull for any help. Best regards, Oleg |