Delphi 6 : using scroll in a DBGrid with WheelMouse

There was a request to make the mouse wheel as the scrolling. I found the code and wanted to save it as well here.

Enjoy

Coffee Cup

//with delphi7

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, DB, DBTables;

type
  TForm1 = class(TForm)
    DataSource1: TDataSource;
    Table1: TTable;
    DBGrid1: TDBGrid;
    procedure FormCreate(Sender: TObject);
    procedure DBGridMouseWheel(Sender: TObject; Shift: TShiftState;
      WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  TWheelDBGrid = class(TDBGrid)
  public
    property OnMouseWheel;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  TWheelDBGrid(DBGrid1).OnMouseWheel := DBGridMouseWheel;
end;

function GetNumScrollLines: Integer;
begin
  SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, @Result, 0);
end;

procedure TForm1.DBGridMouseWheel(Sender: TObject; Shift: TShiftState;
  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
var
  Direction: Shortint;
begin
  Direction := 1;
  if WheelDelta = 0 then
    Exit
  else if WheelDelta > 0 then
    Direction := -1;

  with TDBGrid(Sender) do
  begin
    if Assigned(DataSource) and Assigned(DataSource.DataSet) then
      DataSource.DataSet.MoveBy(Direction * GetNumScrollLines);
    Invalidate;
  end;
end;

end.

https://www.swissdelphicenter.ch/en/showcode.php?id=2142

Jpg Picture or Thumbnail Preview Not Showing On Windows

Ways to resolve Thumbnail preview issues

If you have complaints related to Thumbnail previews on your Windows 10, then simply try these fixes.

  • Check File Explorer Settings
  • Change Visual Effects Settings
  • Clear Thumbnails Cache
  • Modify Windows 10 Registry Settings
  • Edit Group Policy
  • Restore File Explorer Settings

Check File Explorer Settings

  1. Type File Explorer Options in the search box of your Windows 10 system and select the option File Explorer Options.
File Explorer Options.

2. A dialog box namely File Explorer Options will get opened. Here, switch to the View tab, and under the Advanced Settings section, ensure that Always show icons, never thumbnails option is not selected. If it is selected, then unselect it. Then, select OK.

Always show icons, never thumbnails

3. If the option was selected, then deselecting it might solve your problem.

Change Visual Effect Settings

On your Windows 10 system, search View advanced system settings and select the same search result to open it.

View advanced system settings

Next, a dialogue box System Properties will get opened. On the Advanced tab, click the Settings option under the Performance section.

System Properties

The Performance Options dialogue box will get opened. On the Visual Effects tab, under the Custom section, select two checkboxes – Save taskbar thumbnail previews and Show thumbnails instead of icons. Click on OK to save the changes.

Save taskbar thumbnail previews
  • Now, check if thumbnails previews appear again.

Clear Thumbnails Cache

  1. Go to the Search menu and type Disk cleanup. Select the search result Disk Cleanup.
  2. Next, you need to select the system drive on which you want to perform the scan and cleanup. Click OK after the selection.
  3. The drive scanning process will get started. Wait till it finishes.
  4. Now, on the Disk Cleanup for System dialogue box, select Thumbnails and Temporary files checkboxes under Files to delete section. Click OK to delete the selections.
Thumbnails and Temporary files

5. It will delete the current (may be corrupted) Thumbnails cache from your system drive and Windows will create the new cache again on need.

Modify Windows 10 Registry Settings

  1. Press the Windows button and R alphabet on the keyboard together. Type regedit and click on OK.
  2. The Windows Registry Editor page will get opened. Go to the following locations one-by-one and create a DWORD name with “Disable Thumbnails” and set its value to 1 and click OK. (Value 1 = Disabling DWORD, Value 0 = Enabling DWORD.

The locations are

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer

And

  1. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer
Disable Thumbnails”

3. Exit the Registry Editor and restart the system.

Edit Group Policy

  1. Type gpedit.msc in the Windows 10 run box (press Windows and R together) and click OK.
  2. The Local Group Policy Editor page will get opened. Here, on the left panel, follow this location –

User Configuration>Administrative Templates>Start Menu and Taskbar

3. Now, from the right panel, double click on the option Turn off taskbar thumbnails.

Turn off taskbar thumbnails.

4. On the next page, select the Disabled option and click OK.

Disabled

5. Also, on the main Local Group Policy Editor page, move to this location –User Configuration>Administrative Templates>Windows components>File Explorer. Expand File Explorer.

User Configuration

6. From the right panel, double-click on Turn off the display of thumbnails and only display icons.

Turn off the display of thumbnails
Disabled

7. Again select Disabled option and click OK.

8. Now exit the Local Group Policy Editor and restart your Windows 10 system.

Restore File Explorer Settings

  1. On the Search menu of your system, type File Explorer Options, and from the search result, click on File Explorer Options.
  2. The File Explorer Options page will get opened. Here on the General tab, click on Restore Defaults option.
Restore Defaults

3. Perform the same on the View tab.

4. Wait till the restoring gets completed. Click OK.

https://www.linkedin.com/pulse/thumbnail-previews-showing-windows-10-kerneldatarecovery/

Enjoy

Coffee Cup

Delphi Internal Error LA33 and RLink32.dll – Finally Found Out Why [SOLVED]

When doing Delphi App i encounter LA33 and RLink32 error which causes the app to crash during compiling. Sometimes I get away with being able to compile the EXE on some days, but other days, it just won’t do.

 Access violation at address 062B487B in module RLINK32.DLL. Read of address 0C5DOD4A.

I researched and encountered the following solutions

  1. Remove the .res file of your application. This would result in loosing your icon file. So when i do this step, i need to re-attach the icon file again.
  2. Removing the .dcu files from your application. This sometimes work from me but a lot of times, it doesn’t as well.
  3. I had increased the ram of my pc since when i read it, it was a memory problem. So far it sped up my pc but still the problem persists.

I had researched the issue again and found out a very small link that had the same problem as mine that might not exists in a lot of other developers out there. You see, my application is branched out to different companies under the same industry.

Let me explain, so if you have 3 companies buying-and-selling, i would create a single application that is saved 3 times in the same folder. So we have company1.exe, company2.exe and company3.exe.

As it turns out in the project file of the app, when the system uses the word {$R *.res} it tries to read the .res file fo the project. Since i had 3 of them, it made the compiler dizzy which one to choose. So when i erased the .res file before it sort of worked for a while

This is the solution. In the project unit, please change the line to {$R FileName.res} where the FileName is the name of the exe you are creating.

So instead of using {$R *.res} , please write {$R company1.res}

This is the original reply from one of the posts that i found. Thank you Lepe.

This error usually occurs when we save the project 2 times in the same folder with different names, in which case 2 files are created Resource:

Project1.res
MyApplication.res

I've ever had problems like that, and I solved it like this, although now I test with bds2006 and I don't get any warning .

Enjoy

Coffee Cup

https://www.clubdelphi.com/foros/showthread.php?t=50948

Dephi and Quickreport and you want to close the quickreport after printing [SOLVED]

Hi guys, just wanted to share a quicky solution for an age old problem of closing the quickreport after clicking the print button.

This feature allows the system to record all report generated report by the user without allowing them to reprint the same report again if the preview report is seen on the screen.

There are 2 parts to this solutions. 1 is function that will be called. 2 is the function to be called during the afterprint procedure in the quickreport

part 1 – function

procedure CloseAllReportPreviews;
var
  i: Integer;
begin
  try
    for i := Screen.FormCount - 1 downto 0 do
    if Screen.Forms[i].ClassName = 'TQRStandardPreview' then
    begin
      Screen.Forms[i].close;
    end;
  except
    ShowMessage('Please close all existing reports');
  end;
end;

part 2 – afterprint in quickreport

procedure TQuickReport.QuickRepAfterPrint(Sender: TObject);
begin
    CloseAllReportPreviews;
  end;
end;

Enjoy

Coffee Cup

Delphi Quickreport Disabling Load and Save buttons [SOLVED]

A recent client of mine insisted that he wanted the app to remove the load and save button for the quickreports.

After searching for around 2 hours, i found the solution from mr.wu

So thank you mr.wu

Here is the code

another way can solve this problem.
(1)append
    uses  ...QRPrntr, QRPrev,...
(2)complete the OnPreview method for the QuickRep as following:
procedure TqrpLabelGrader.QuickRep1Preview(Sender: TObject);
var
  qrStandardPreview: TQRStandardPreview;
begin
  qrStandardPreview:=TQRStandardPreview.CreatePreview(Self, TQRPrinter(Sender));
  qrStandardPreview.SaveReport.Enabled := False;
  qrStandardPreview.LoadReport.Enabled := False;
  qrStandardPreview.Show;
end;
HPH,
wu yong

Enjoy

Coffee Cup

http://www.delphigroups.info/2/b2/390705.html

ClipboxTab , SmoothSearch , Dexpredict , FreeCounterStat [FIXED]

Recently one of the websites i was handling started to show strange. When you load the main page, and click with any link or part of the website, it redirects to another page outside of the website.

At first i was puzzled what was causing it. I thought the website has been infultrated or hacked. But it seems everything is still intact.

I separated the main page and tried to dismantle it from there. And you know, what i was the cause, it was a php counter that i got into the website. It seems to be in sleep mode until around 3 years later.

Here are some of the links when you get redirected

https://dexpredict.com/jump/next.php?r=3001031
https://www.smoothsearch.online/install?pubid=2777&productid=30551&clickid=US168345805110000TPHTV422920713914V18
https://clipboxtab.com/install?pubid=2777&productid=30570

Now i know you are dying to know the source. And here it is

https://www.freecounterstat.com

The website gives out a link that you embed in your website

<div id="sfcybjc22f3ctd27lelnzssl4fl8422sw7h"></div>
<script type="text/javascript" src="https://counter10.optistats.ovh/private/counter.js?c=ybjc22f3ctd27lelnzssl4fl8422sw7h&down=async" async></script>
<noscript>
<a href="https://www.freecounterstat.com" title="free hit counter">
<img src="https://counter10.optistats.ovh/private/freecounterstat.php?c=ybjc22f3ctd27lelnzssl4fl8422sw7h" border="0" title="free hit counter" alt="free hit counter">
</a>
</noscript>

The culprit is the first line of the code

<div id="sfcybjc22f3ctd27lelnzssl4fl8422sw7h"></div>

So that’s it. Hope somebody don’t need to learn it the hard way. It’s better you create your own page counter. Either using php & mysql or a txt file to store the current value.

Coffee Cup

Delphi Error – E2151 Could not load RLINK32.DLL

Delphi Error – E2152 Wrong or corrupted version of RLINK32.DLL

  • fatal error saying:
    Internal Error LA30
    Access violation at address 0A3CA3E5 in module ‘RLINK32.DLL’
    Read of address 0C5C01F0

What steps you can do

  • Deleting .dcus and rebuilding all of your packages
  • removed all DCU, and .res files, and rebuilt,
  • third party component packages interfering

I hope you are helped by these suggestions. Drop me a line if you want to ask questions.

Enjoy

Coffee Cup

How to set up my Razer Seiren Mini

Recently i have acquired a Razen Seiren Mini to test voice recording without any background noice and clear crisp quality. Hera are the steps on how to install on your pc.

To set up your Razer Seiren Mini, follow the steps below.

  1. Take the device out of the box and assemble the base.
  2. Fasten it securely to the thread mount of your Razer Seiren Mini.
  3. Connect the microphone to the USB port of your PC using the Micro-USB to USB cable.
  4. Right-click on the sound icon on the system tray of your PC and select “Open Sound settings” and set Razer Seiren Mini as the default Input device.

https://support.microsoft.com/en-us/windows/fix-microphone-problems-5f230348-106d-bfa4-1db5-336f35576011

  1. Open Start > Settings > System > Sound
  2. In the input, select a microphone to see its properties.
  3. In the input volume, please make sure the blue bar adjusts as you speak into the microphone.
  4. If it doesn’t, go to Test your microphone and Start test.

Enjoy

Coffee Cup

Windows 10 100% Disk Usage Problem [FIXED] 

FIX-Windows-10-100-Percent-Disk-Usage-Problem

Sometimes you encounter a PC that when you look at the task manager, you go ‘holy cow!’, it’s running on 100% disk usage for a long, long time.

Believe me, that’s quite normal but solvable.

Here are the steps that I did to help bring it down.

1. Press   + R and type devmgmt.msc in the Run, hit Enter key to open Device Manager snap-in.

Device Manager Windows 10

2. In the Device Manager window, expand IDE ATA/ATAPI controllers and right click on Standard SATA AHCI Controller, select Properties.

FIX Windows 10 100 Percent Disk Usage Problem

3. In the property sheet, switch to Driver tab and click Driver Details.

FIX Windows 10 100 Percent Disk Usage Problem

4. If the Driver File Details window shows storahci.sys driver listed there, it means you’re running inbox driver and hence it is possible to disable MSI mode. Click OK.

FIX Windows 10 100 Percent Disk Usage Problem

5. Back on the property sheet, switch to Details tab. Against Property, select Device instance path from drop-down and note down the Value mentioned there.

FIX Windows 10 100 Percent Disk Usage Problem

6. Press  + R and put regedit in Run dialog box to open Registry Editor (if you’re not familiar with Registry Editor, then click here). Click OK.

Windows 10 Registry Editor

7. In the Registry Editor window, navigate to following registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\<AHCI Controller Value>\Device Parameters\Interrupt Management\MessageSignaledInterruptProperties

Substitute <AHCI Controller Value> we got in step 5.

FIX Windows 10 100 Percent Disk Usage Problem

8. In the right pane of MessageSignaledInterruptProperties key, look for the registry DWORD (REG_DWORD) named MSISupported which should be corresponding to Value 1 as its Data. Double click on the DWORD to modify its value:

FIX Windows 10 100 Percent Disk Usage Problem

9. Finally, set the Value data as 0 and click OK. Close Registry Editor and reboot. After restarting your machine, the 100% disk usage problem should disappear.

Thanks to this link

https://www.kapilarya.com/fix-windows-10-100-percent-disk-usage-problem

Enjoy

Coffee Cup

How to Disable Cortana Permanently Using the Windows Registry

  1. Right-click the Windows icon and select Run to open the command prompt.
  2. Type regedit and press Enter.
  3. Navigate to HKEY_Local_Machine > SOFTWARE > Policies > Microsoft > Windows, then right-click the Windows directory and select New > Key.
  4. Name the new folder Windows Search.
  5. Right-click the Windows Search folder and select New > DWORD (32-bit) Value.
  6. Name the new file AllowCortana.
  7. Double-click the AllowCortana file to open it, set the value to 0, then select OK.
  8. Close the Registry Editor and restart your computer.