Jump to content

ChrisChuah

Members
  • Content Count

    108
  • Joined

  • Last visited

Everything posted by ChrisChuah

  1. Ok. I will try to write a small part of the code to see if i can reproduce the same error or not thanks chris
  2. We are just learning. I am still learning too I tried not to create the form but to call showmodal each time user click on the update button But i will get a problem is that cannot Showmodal when the form is visible. In the FormClose of aircrafttype form, i set it to caHide instead of caFree and i have that error. I feel that even though i have use delphi since Delphi 1, i am still learning how to use this language. Delphi 6 was the most stable version that i used and I am still using that now to do minor changes to those application written in 2007.
  3. The DetailForm close event will have Action := caFree I tried this way ===== Ghosting Windows procedure DisableProcessWindowsGhosting; var DisableProcessWindowsGhostingProc: procedure; begin DisableProcessWindowsGhostingProc := GetProcAddress( GetModuleHandle('user32.dll'), 'DisableProcessWindowsGhosting'); if Assigned(DisableProcessWindowsGhostingProc) then DisableProcessWindowsGhostingProc; end; begin Application.Initialize; DisableProcessWindowsGhosting; TStyleManager.TrySetStyle('Iceberg Classico'); Application.CreateForm(TDataModule1, DataModule1); Application.CreateForm(TfrmMain, frmMain); Application.Run; end. ======================= But will also have the same effect that open and close the form too many times will result in hanging of the application or the form will not show. Only when i removed the Style Manager, then i will not have this problem. The Grid is also having its own DrawColumnCell Event ===================== procedure TfrmMain.dbgACTDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var l_bitmap : TBitmap; l_rect : TRect; l_bmpWidth, l_width : integer; l_str : string; begin with dbgACT do begin if (gdSelected in State) then begin Canvas.Font.Color := clBlack; Canvas.Brush.Color := clLime; end else begin if ( (DataSource.Dataset).RecNo mod 2 = 0) then begin if Canvas.Brush.Color = Color then begin Canvas.Brush.Color := clSkyBlue; end; end; end; end; l_rect := Rect; l_str := Column.Field.DisplayText; l_width := dbgACT.Canvas.TextExtent(l_str).cx + 5; if Column.FieldName = 'ROW_ID' then begin l_bitmap := TBitmap.create; try ImageList2.GetBitmap(tsACT.ImageIndex, l_bitmap); l_bmpWidth := (Rect.bottom - Rect.Top); l_rect.Right := Rect.Left + l_bmpWidth; dbgACT.Canvas.StretchDraw(l_rect, l_bitmap); finally l_bitmap.Free; end; // cc : reset the output rectangle l_rect := Rect; l_rect.Left := l_rect.Left + l_bmpWidth; l_width := 5 + dbgACT.Canvas.TextExtent(l_str).cx; end; if (l_width > Column.Width) then Column.Width := l_width; dbgACT.DefaultDrawColumnCell(l_rect, DataCol, (Column as TColumn), State); end; ==================== But not sure if this affected the style manager or not regards chris
  4. Hi When the database table is updated and i use dbgrid.datasource.dataset.refresh, the dbgrid is refreshed back to the first row. Is it possible to refresh the grid without going back to the first row? This is because if there is frequent update to the database and this Refresh notification is sent to my app each time another app updates the table, the dbgrid will always move back to the first row when it is refreshed. Any advise regards chris
  5. ChrisChuah

    DBGrid repaint or refresh when dataset is refreshed

    Thanks. need to use locate with disable/enable controls so that the table will not have moving effect. However, for my dataset, it has 50 columns but the dbgrid can only show first 10 columns on the screen. If need to show next 10 columns, i will need to scroll to the next 10 columns. So, when i am looking at the next 10 columns and the table refreshed, can the refresh go to the next 10 columns rather than always go back to the 1st 10 columns? regards cris
  6. ChrisChuah

    DBGrid repaint or refresh when dataset is refreshed

    hi i have tried using gotobookmark on TQuery with TClientDataset and it could not work. Will try to use the locate function. thanks
  7. ChrisChuah

    DBGrid repaint or refresh when dataset is refreshed

    hi ok i will try it with the locate function for the disablecontrols and enablecontrols thanks chris
  8. ChrisChuah

    DBGrid repaint or refresh when dataset is refreshed

    If there is frequent update to the table, then the user will see the table moving up and down (always locating the record) isnt it? will this (record pointer moving up and down on the grid) happen?
  9. Hi Is there a way to auto detect when there is no mouse activity and the VCL application will log out for users? thanks chris
  10. ChrisChuah

    auto close or logout when no mouse activity

    Hi I managed to implement it in windows using this event TfrmMain : TForm Gauge1 : TGauge; tmrInactivity: TTimer; procedure FormCreate(Sender: TObject); procedure tmrInactivityTimer(Sender: TObject); private FInactivityTimeout : cardinal; FInactivityCounter : cardinal; // cc : application event to handle key down and left mouse click // cc : for activity timeout procedure ApplicationEventMsg(var Msg: tagMSG; var Handled: Boolean); public end; procedure TfrmMain.FormCreate(Sender: TObject); var l_ini : TIniFile; begin // this event msg is to capture keyboard and mouse event Application.OnMessage := ApplicationEventMsg; // cc : get the amount of seconds allowed before timeout l_ini := TIniFile.create(ChangeFileExt(Application.ExeName, '.ini')); FInactivityTimeout := l_ini.ReadInteger('Main', 'Inactivity Timeout', 60); Gauge1.MaxValue := FInactivityTimeout; Gauge1.MinValue := 0; FInactivityCounter := 0; l_ini.Free; end; procedure TfrmMain.tmrInactivityTimer(Sender: TObject); begin // Inactivity timeout will disconnect every connection tmrInactivity.Enabled := false; if (not DataModule1.getLoginSuccess) then begin FInactivityCounter := 0; Gauge1.Progress := 0; tmrInactivity.Enabled := true; exit; end; if (FInactivityCounter > FInactivityTimeout) then begin DataModule1.closeAll; end; FInactivityCounter := 0; Gauge1.Progress := 0; end else begin FInactivityCounter := FInActivityCounter +1; Gauge1.Progress := FInactivityCounter; end; tmrInactivity.Enabled := true; end;
  11. Hi I am using TSQLQuery, TClientDataSet and TDataSetProvider with DBGrid If i want to sort the DBGrid based on title column click, i can use the event OnTitleClick on DBGrid ClientDataSet.IndexFieldsName := Column.FieldName However, this will sort the Field in ascending order. How can i sort it in descending order? please advise regards chris
  12. ChrisChuah

    DBGrid sort descending on Column Title Click

    Hi I have another question. After i use the AddIndex and set the IndexName to the index field created, how can i get back the information of what index field is used and what is the sorting order (asc or desc) e.g. l_indexName := 'ABN_REM' + '_INDEX'; l_indexes := TStringList.create; (TntDBGrid1.DataSource.DataSet as TClientDataSet).GetIndexNames(l_indexes); if l_indexes.IndexOf(l_indexName) > -1 then (TntDBGrid1.DataSource.DataSet as TClientDataset).DeleteIndex(l_indexName); l_indexes.Free; (TntDBGrid1.DataSource.DataSet as TClientDataset).AddIndex(l_indexName, 'FREE_REM', [ixDescending],'','',0 ); (TntDBGrid1.DataSource.DataSet as TClientDataset).IndexName := l_indexName; In the above code, i have set the IndexName to 'ABN_REM_INDEX' with field 'FREE_REM' used and sort in descending order. So, how can i get back this information that the field name 'FREE_REM' is used and the sorting is in descending order? regards chris
  13. ChrisChuah

    DBGrid sort descending on Column Title Click

    hi Thanks. I will use the AddIndex function to do the sorting. regards chris
  14. Hi I am using TSQLQuery, TClientDataSet and TDataSetProvider with DBGrid I will click on the record row in the middle of the grid and the grid shows that it is highlighted HOwever, when i close and open the ClientDataSet to refresh the data, i would use the bookmark to go back to the last bookmark before the Client dataset is Close l_bookmark := TntDBGrid1.Datasource.DataSet.GetBookmark; TntDBGrid1.DataSource.DataSet.Close; TntDBGrid1.DataSource.Dataset.Open; TntDBGrid1.DataSource.DataSet.GotoBookmark(l_bookmark); TntDBGrid1.DataSource.Dataset.FreeBookmark(l_bookmark); After open, the indicator is shown correctly on the dbgrid but the highlighted row is on the first row. see pic please advise regards chris
  15. Hi I am not sure if this function affected the drawing procedure TForm1.ClientDataSet1AfterOpen(DataSet: TDataSet); var l_index : integer; l_fieldName : string; begin for l_index := 0 to ClientDataSet1.FieldCount - 1 do begin l_fieldName := ClientDataSet1.Fields[l_index].FieldName; ClientDataSet1.Fields[l_index].DisplayWidth :=10; if (l_fieldName = 'SDT') or (l_fieldName = 'EST_D') or (l_fieldName = 'LAST_D') or (l_fieldName = 'ACT_D') or (l_fieldName = 'CREATED_AT') or (l_fieldName = 'UPDATED_AT') then ClientDataSet1.Fields[l_index].OnGetText := getDateTimeStr else if (l_fieldName = 'STIME') then ClientDataSet1.Fields[l_index].OnGetText := getTimeStr else if (l_fieldName = 'SDATE') then ClientDataSet1.Fields[l_index].OnGetText := getDateStr else if (l_fieldName = 'ORDEST_N_C') or (l_fieldName = 'FREE_REM') then ClientDataSet1.Fields[l_index].OnGetText := getForeignStr; end; Dataset.Last; end; procedure TForm1.TntDBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var l_bitmap : TBitmap; l_rect : TRect; l_bmpWidth, l_width : integer; l_str : string; begin if (ClientDataSet1.RecNo mod 2 = 0) then begin if TntDBGrid1.Canvas.Brush.Color = TntDBGrid1.Color then begin TntDBGrid1.Canvas.Brush.Color := clSkyBlue; end; end; l_rect := Rect; l_str := Column.Field.DisplayText; if Column.FieldName = 'ROW_ID' then begin l_bitmap := TBitmap.create; try ImageList3.GetBitmap(1, l_bitmap); l_bmpWidth := (Rect.bottom - Rect.Top); l_rect.Right := Rect.Left + l_bmpWidth; TntDBGrid1.Canvas.StretchDraw(l_rect, l_bitmap); finally l_bitmap.Free; end; // cc : reset the output rectangle l_rect := Rect; l_rect.Left := l_rect.Left + l_bmpWidth; l_width := 5 + TntDBGrid1.Canvas.TextExtent(l_str).cx; <== if (l_width > Column.Width) then <== Column.Width := l_width; <== end; TntDBGrid1.DefaultDrawColumnCell(l_rect, DataCol, (Column as TTntColumn), State); end; As i store all the dates as Unix Epoch format. hence i need to translate all the values to date time format when drawn on the grid. However, is there a way to know when the drawing on the grid is completed? Or is there a better way to make the grid draw out faster? Seems like if i dont make it auto size for every column, the drawing is faster. The longest column is the Foreign Characters and the resizing took quite long there Is there a way to auto size and auto fit the column which is not done during the drawing part? please advise regards chris
  16. I just found out that i can use the dataset to refresh rather than Open and close. The dbgrid will refresh with updated content. Now i have another problem is when i open the dataset, the dbgrid is filled to the bottom and it will somehow stop there.. i need to scroll down to request it to draw again. anyone have this problem? is there a way to scroll all the way down the grid automatically once the drawing is completed? please see this video on the problem.. anyone can advise? source procedure TfrmMain.dbgABNDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var l_bitmap : TBitmap; l_rect : TRect; l_bmpWidth, l_width : integer; l_str : string; begin if ( (dbgABN.DataSource.Dataset as TClientDataset).RecNo mod 2 = 0) then begin if dbgABN.Canvas.Brush.Color = dbgABN.Color then begin dbgABN.Canvas.Brush.Color := clSkyBlue; end; end; l_rect := Rect; l_str := Column.Field.DisplayText; if Column.FieldName = 'ROW_ID' then begin l_bitmap := TBitmap.create; try ImageList2.GetBitmap(0, l_bitmap); l_bmpWidth := (Rect.bottom - Rect.Top); l_rect.Right := Rect.Left + l_bmpWidth; dbgABN.Canvas.StretchDraw(l_rect, l_bitmap); finally l_bitmap.Free; end; // cc : reset the output rectangle l_rect := Rect; l_rect.Left := l_rect.Left + l_bmpWidth; end; l_width := 5 + dbgABN.Canvas.TextExtent(l_str).cx; if (l_width > Column.Width) then Column.Width := l_width; dbgABN.DefaultDrawColumnCell(l_rect, DataCol, (Column as TTntColumn), State); end; Screen_Recording_2022-06-30_at_9_50.33_AM.mp4
  17. Thank you. Seems like i did not see that bookmarks are invalidated when dataset is closed and opened again. Then how can i refresh the dataset if i do not close and open it?
  18. ChrisChuah

    DBGrid sort descending on Column Title Click

    Thank you for your help
  19. Hi Is there a link to download Indy as well as installation manual for Lazarus running on Ubuntu X86_64? please advise regards chris
  20. ChrisChuah

    Indy download and installation on Lazarus running on Ubuntu

    thank you justin Will try it out on lazarus
  21. ChrisChuah

    TEdit Text cannot align vertical centered

    Hi For the TLabel, i can align the text vertically centre using the Layout properties. However, for TEdit, there isnt any option for this. Please help on how i can have the TEdit text aligned vertically centered. regards chris
  22. ChrisChuah

    TEdit Text cannot align vertical centered

    thanks remy Its working now. not sure why i could not connect to that link when i was in office thanks chris
  23. ChrisChuah

    TEdit Text cannot align vertical centered

    Hi Thank you. That link does not work. Just have to stick to the underlying windows control. regards chris
  24. Hi Each time i send a packet of data to the broadcast address, the same packet will be received back again. How can i 1. control the idUDPClient to ignore the packet 2. How to determine the ip address is a broadcast address in the network please advise regards chris
  25. Hi On my mac, it seems that i have many network interfaces. I used Indy GStack.GetLocalAddressList to obtain all these interface name and IP address. Stack Local Address 0: en0: FE80:0:0:0:102B:BAE3:A50E:FEDA Stack Local Address 1: en0: 192.168.1.10 Stack Local Address 2: en1: FE80:0:0:0:C55:FF1F:977A:4ECD Stack Local Address 3: en1: 192.168.1.11 Stack Local Address 4: awdl0: FE80:0:0:0:380D:36FF:FE0A:D127 Stack Local Address 5: llw0: FE80:0:0:0:380D:36FF:FE0A:D127 Stack Local Address 6: utun0: FE80:0:0:0:FE2C:6391:70B1:32E5 Stack Local Address 7: utun1: FE80:0:0:0:D512:288C:E8D7:52E1 Stack Local Address 8: utun2: FE80:0:0:0:CE81:B1C:BD2C:69E Stack Local Address 9: bridge100: 172.16.90.1 Stack Local Address 10: bridge100: FE80:0:0:0:787B:8AFF:FE3C:7864 Stack Local Address 11: bridge101: 192.168.83.1 Stack Local Address 12: bridge101: FE80:0:0:0:787B:8AFF:FE3C:7865 Stack Local Address 13: bridge102: 192.168.84.1 Stack Local Address 14: bridge102: FE80:0:0:0:787B:8AFF:FE3C:7866 Stack Local Address 15: bridge103: 192.168.85.1 Stack Local Address 16: bridge103: FE80:0:0:0:787B:8AFF:FE3C:7867 Stack Local Address 17: bridge104: 172.16.49.1 Stack Local Address 18: bridge104: FE80:0:0:0:787B:8AFF:FE3C:7868 If i want to send a broadcast packet onto 192.168.84.255 (Bridge102), How can i specify it in idUDPClient? Or will idUDPClient able to automatically send it out via that interface? Please advise regards chris
×