1. Disable Caption Close Button

  2. Enable Caption Close Button

  3. Font Add

  4. Font Remove

  5. Start New Browser Window

  6. Get Associated Program


Home

 

Pages: 1  |  2  |  3  |  4  |  5 |


Disable Caption Close Button

 

procedure DisableCaptionCloseButton(const FormHandle: THandle);
var
hMnu: THandle;
begin
 

hMnu := GetSystemMenu(FormHandle, FALSE);
EnableMenuItem(hMnu, SC_MINIMIZE, SC_CLOSE or MF_GRAYED);
 

end;

 

Back to Top

Enable Caption Close Button

 

procedure EnableCaptionCloseButton(const FormHandle: THandle);
var
hMnu: THandle;
begin
 

hMnu := GetSystemMenu(FormHandle, FALSE);
EnableMenuItem(hMnu, SC_MINIMIZE, SC_CLOSE or MF_ENABLED);
 

end;
 

 
Back to Top

Font Add

function FontAdd(const FontFilename: string): Boolean;
begin
 
result := (AddFontResource(PChar(ExtractFilePath(ParamStr(0) + FontFilename))) <> 0);
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
 
end;

 

Back to Top

 


Font Remove

function FontRemove(const FontFilename: string): Boolean;
begin
 
result := RemoveFontResource(PChar(ExtractFilePath(ParamStr(0) + FontFilename)));
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
 
end;

 

Back to Top

 


Start New Browser Window

uses DdeMan;

procedure StartNewBrowserWindow(const URL: string);
var
DDEConv: TDDEClientConv;
URLFired: bool;
App: string;
UpApp: string;
p: array[0..MAX_PATH] of Char;
begin


UrlFired := False;
App := GetAssociatedProgram('HTM');  // <<-- Function GetAssociatedProgram is here
UpApp := Uppercase(App);
Delete(App, Pos('.EXE', UpAPP), Length(App));
if Pos('NETSCAPE.EXE',
   UpApp) > 0 then
begin
        DDEConv := TDDEClientConv.Create(nil);
        DDEConv.ServiceApplication := App;
        if DDEConv.SetLink('NETSCAPE', 'WWW_OpenURL') then
            if DDEConv.RequestData(URL + ',,0x0,0x0') <> nil then
                if DDEConv.SetLink('NETSCAPE', 'WWW_Activate') then
                URLFired := DDEConv.RequestData('0xFFFFFFFF,0x0') <> nil;
    DDEConv.Free;
end
else if Pos('IEXPLORE.EXE',
    UpApp) > 0 then
begin
        DDEConv := TDDEClientConv.Create(nil);
        DDEConv.ServiceApplication := App;
        if DDEConv.SetLink('iexplore', 'WWW_OpenURL') then
            if DDEConv.RequestData(URL + ',,0') <> nil then
                if DDEConv.SetLink('iexplore', 'WWW_Activate') then
                    URLFired := DDEConv.RequestData('0,0') <> nil;
    DDEConv.Free;
end;
if UrlFired = False then
    WinExec(StrPCopy(@p, URL), SW_SHOWNORMAL);
 

end;
 

 
Back to Top

Get Associated Program

 

function GetAssociatedProgram(const Ext: string): string;
var
{$IFDEF WIN32}
reg: TRegistry;
s: string;
{$ELSE}
WinIni: TIniFile;
WinIniFileName: array[0..MAX_PATH] of Char;
s: string;
{$ENDIF}
begin
 

{$IFDEF WIN32}
        s := '';
        reg := TRegistry.Create;
        reg.RootKey := HKEY_CLASSES_ROOT;
        if reg.OpenKey('.' + ext + '\shell\open\command',
            False) <> False then
begin
    {The open command has been found}
    s := reg.ReadString('');
    reg.CloseKey;
end
else
begin
    {perhaps thier is a system file pointer}
    if reg.OpenKey('.' + ext,
        False) <> False then
        begin
            s := reg.ReadString('');
            reg.CloseKey;
            if s <> '' then
            begin
                {A system file pointer was found}
                if reg.OpenKey(s + '\shell\open\command',
                    False) <> False then
                    {The open command has been found}
                    s := reg.ReadString('');
                reg.CloseKey;
            end;
        end;
    end;
{Delete any command line, quotes and spaces}
if Pos('%', s) > 0 then
    Delete(s, Pos('%', s), Length(s));
if ((Length(s) > 0) and
    (s[1] = '"')) then
    Delete(s, 1, 1);
if ((Length(s) > 0) and
    (Pos('"', s) > 0)) then
    Delete(s, Pos('"', s), Length(s));
while ((Length(s) > 0) and
    (s[Length(s)] = #32)) do
    Delete(s, Length(s), 1);
{$ELSE}
    GetWindowsDirectory(WinIniFileName, SizeOf(WinIniFileName));
    StrCat(WinIniFileName, '\win.ini');
    WinIni := TIniFile.Create(WinIniFileName);
    s := WinIni.ReadString('Extensions', ext, '');
    WinIni.Free;
    {Delete any command line}
    if Pos(' ^', s) > 0 then
        Delete(s, Pos(' ^', s), Length(s));
{$ENDIF}
    Result := s;
 

end;

 
Back to Top

Copyright 2006  [PatilanSoft]. All rights reserved.