i have a problem with SHGetFileInfo. I am using FPC 2.6.2 with Lazarus 1.0.14, here is the code:
procedure x;
var
FI: SHFILEINFO;
icon: ticon;
begin
SHGetFileInfo('app.exe', 0, FI, SizeOf(FI), SHGFI_SYSICONINDEX or SHGFI_ICON or SHGFI_LARGEICON);
icon := TIcon.Create;
icon.Handle := FI.hIcon;
icon.SaveToFile('extracted.ico');
end;
The problem is it produces icon file with black background instead od transparent. Here is how it looks like:
http://i.imgur.com/5BF3xbT.jpg
When i compile the same code in Delphi, it works perfectly. Icon has transparent background.
I would appreciate if anyone could help me to solve this problem :-)
I have same problem time ago. LCL seems can't have full alpha support for TIcon, so you must use another similar component. I tried TKIcon and it works. You can find here http://www.tkweb.eu/en/delphicomp/kicon.html
I post a sample procedure to extract a icon. It is very simple.
procedure ExtractIconAndSave(xpath: string);
var
FileInfo: SHFILEINFO;
Icon: KIcon.TIcon; //Don't confused with Graphics.TIcon
begin
//Get icon handle
SHGetFileInfo(PChar(xpath), 0, FileInfo, SizeOf(FileInfo), SHGFI_SYSICONINDEX or SHGFI_ICON or SHGFI_LARGEICON);
//Check if SHGetFileInfo get the icon handle
if FileInfo.hIcon <> 0 then
begin
//Use kIcon's TIcon - It supports alpha 32bpp
Icon := KIcon.TIcon.Create;
try
//Load icon handle in TKIcon and save it in a file
Icon.LoadFromHandle(FileInfo.hIcon);
Icon.SaveToFile('extracted.ico');
finally
DestroyIcon(FileInfo.hIcon);
FreeAndNil(Icon);
end;
end;
end;
Related
What is the best way in FMX to create a grid that supports bidimode and righttoleft languages
I have tried fmxrtl but it has many errors
Thanks
Is your app only for Windows ? If yes, I use a function to detect if it's a Bidi string and then use TTextLayout my test here
Else, try to use SKIA4Delphi (XE7+)Supporting right to left
I test an Android little app ScreenShot
procedure TForm1.Grid1DrawColumnCell(Sender: TObject; const Canvas: TCanvas;
const Column: TColumn; const Bounds: TRectF; const Row: Integer;
const Value: TValue; const State: TGridDrawStates);
begin
if (Column.Index=1) AND (Row>=1)
then begin
Canvas.Fill.Color:=TAlphaColors.Red;
Canvas.FillText(Bounds,Value.ToString,false,1,[TFillTextFlag.RightToLeft],TTextAlign.Leading);
end
else Column.DefaultDrawCell(Canvas,bounds,row,value,state);
end;
I'm trying to drop a shadow on a borderless window using Qt in windows.
I succeeded in dropping the shadow when launching the application, referring to the following article.
Borderless Window Using Areo Snap, Shadow, Minimize Animation, and Shake
Borderless Window with Drop Shadow
But I encountered the problem that the shadow will disappear if the application is deactivated and reactivated (
In other words, click the other applications, and click my application again.)
Perhaps my implementation is not good enough.
I'm glad if you have some ideas for this issue.
I'm trying to imprement Qt with Go bindings
Here is the code snippet:
package qframelesswindow
import (
"unsafe"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/widgets"
win "github.com/akiyosi/w32"
)
func (f *QFramelessWindow) SetNativeEvent(app *widgets.QApplication) {
filterObj := core.NewQAbstractNativeEventFilter()
filterObj.ConnectNativeEventFilter(func(eventType *core.QByteArray, message unsafe.Pointer, result int) bool {
msg := (*win.MSG)(message)
lparam := msg.LParam
hwnd := msg.Hwnd
var uflag uint
uflag = win.SWP_NOZORDER | win.SWP_NOOWNERZORDER | win.SWP_NOMOVE | win.SWP_NOSIZE | win.SWP_FRAMECHANGED
var nullptr win.HWND
shadow := &win.MARGINS{0, 0, 0, 1}
switch msg.Message {
case win.WM_CREATE:
style := win.WS_POPUP | win.WS_THICKFRAME | win.WS_MINIMIZEBOX | win.WS_MAXIMIZEBOX | win.WS_CAPTION
win.SetWindowLong(hwnd, win.GWL_STYLE, uint32(style))
win.DwmExtendFrameIntoClientArea(hwnd, shadow)
win.SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, uflag)
return true
case win.WM_NCCALCSIZE:
if msg.WParam == 1 {
// this kills the window frame and title bar we added with WS_THICKFRAME and WS_CAPTION
result = 0
return true
}
return false
case win.WM_GETMINMAXINFO:
mm := (*win.MINMAXINFO)((unsafe.Pointer)(lparam))
mm.PtMinTrackSize.X = int32(f.minimumWidth)
mm.PtMinTrackSize.Y = int32(f.minimumHeight)
return true
default:
}
return false
})
app.InstallNativeEventFilter(filterObj)
}
All source code is in my repository;
akiyosi/goqtframelesswindow
WM_NCCALCSIZE:
If wParam is TRUE, the application should return zero or a combination
of the following values.(In document)
And also:
When wParam is TRUE, simply returning 0 without processing the
NCCALCSIZE_PARAMS rectangles will cause the client area to resize to
the size of the window, including the window frame. This will remove
the window frame and caption items from your window, leaving only the
client area displayed.
Starting with Windows Vista, simply returning 0 does not affect extended frames, only the standard frame will be removed.
EDIT:
Set the return value with the DWL_MSGRESULT instead of result = 0.
This bit of Code here creates a scrollview of buttons to allow me select from a list of different "tickets"
SearchResultButton(Button(text=str(Datarray2[i]),id=str(Datarray2[i]),on_press=self.Pressbtn ))
self.ids.SearchResult.add_widget(SearchResultButton)
From there it opens this function, which should set a variable (In this case "UpdateTicketNum") which will be used in another function to set the label text in another screen.
def Pressbtn(self, SearchResultButton):
global UpdateTicket
UpdateTicket = OPENTicket
woo = SearchResultButton.text
print(SearchResultButton.text)
wow = [blank.strip() for blank in woo.split(',')]
print("\n\n\n\n")
global UpdateTicketNum
UpdateTicketNum = (wow[0])
self.manager.get_screen('UpdateTicket').UpdateOpen()
At this point it opens up the sqlite DB and double checks that the TicketNumber is valid. The issue comes in when trying to access the label inside the kv build
def UpdateOpen(self):
print("TESTSETST")
conn = sqlite3.connect('TicketData.db', timeout=10)
UD = conn.cursor()
UD.execute('SELECT TicketNumber FROM TicketData WHERE TicketNumber = ?',(UpdateTicketNum,))
tips = UD.fetchone()
print(tips[0])
tipsy = tips[0]
UpdatedLabelTexT = tipsy
sm.current=('UpdateTicket')
UpdateTicket.ids.UpdateLabels['text']=(UpdatedLabelTexT)
The UpdateTicket.ids.UpdateLabels['text']=UpdatedLabelText] field always claims to be a property of the scrollview buttons even though I am initializing it inside another class, and with different parameters. apologies if this question is poorly formatted. but 3 days of dying trying to figure this out and I snapped.
Here is the bit in KV
<UpdateTicket>
name: 'UpdateTicket'
on_enter:
root.UpdateOpen()
orientation: "vertical"
FloatLayout:
canvas.before:
Color:
rgba: .0, .6, 1, 1
Rectangle:
pos: self.pos
size: self.size
source: "lights.jpg"
Label:
id: UpdateLabels
text: "filler"
multiline: False
size_hint: (None, None)
size: (root.width/5,root.height/20)
pos_hint:{'center_x': .5,'center_y': .5 }
and how I initialize the screen
sm.add_widget(UpdateTicket(name='UpdateTicket'))
I found the solution that worked for me. when first initializing the app
class SampleApp(App)
return sm(to build the application)
I needed to replace that return SM with
global root
return sm
root = ScreenManager()
return root
And that appeared to fix my issue. thanks for reading
I am using wkhtmltopdf version 0.12.2.1 (with patched qt) to render my reactJs app! It worked fine, until I added the react-pdf-js lib to render the pdf generated inside my app. I followed the code described on react-pdf-js documentation (see https://www.npmjs.com/package/react-pdf-js) to make it work.
The pdf is rendered inside my page, and it looks pretty cool indeed. But when I try to run wkhtmltopdf again, to generate a pdf of any page of my app, the following error is returned:
desenv01#desenv01-PC:~$ wkhtmltopdf -O Landscape --print-media-type --debug-javascript http://localhost:3000/report/1 report.pdfLoading pages (1/6)
Warning: undefined:0 ReferenceError: Can't find variable: Float64Array
Warning: http://localhost:3000/assets/js/app.js:46789 SyntaxError: Parse error
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Then, I went to my app.js to see what's on line 46789:
set href(href) {
clear.call(this);
parse.call(this, href);
},
get protocol() {
return this._scheme + ':';
},
set protocol(protocol) {
if (this._isInvalid)
return;
parse.call(this, protocol + ':', 'scheme start');
},
The error happens on the line that says parse.call(this, href);, which is part of pdf.combined.js script.
I could not find any solution online so I wondered if there is anyone who might know if I did something wrong or a way to work around it.
Thanks..
I ran into this using wkthmltopdf 12.3 and 12.4 because I have my IDE set to nag me for using var instead of let. The problem is the older Qt engine powering those versions of the program doesn't recognize new-style, ES6 keywords. Not sure if you can down-convert React. Otherwise you can try the bleeding edge versions which use a newer Qt.
I have same problem. I fixed it by modify some code that i think it is new in JS. let keyword (ES5) and template literals (ES6).
generateRandomColor= function () {
let maxVal = 0xFFFFFF; // 16777215
let randomNumber = Math.random() * maxVal;
randomNumber = Math.floor(randomNumber);
randomNumber = randomNumber.toString(16);
let randColor = randomNumber.padStart(6, 0);
return `#${randColor.toUpperCase()}`
}
I modify above code into below
generateRandomColor = function () {
var maxVal = 0xFFFFFF;
var randomNumber = Math.random() * maxVal;
randomNumber = Math.floor(randomNumber);
randomNumber = randomNumber.toString(16);
var randColor = randomNumber.padStart(6, 0);
return "#" + randColor.toUpperCase();
}
How can I change rcTarget in a filter?
Source and Target Rectangles in Video Renderers
I want, example in free pascal and DSpack.
My project is to work with 720x576 video format. If I can change a filter rcTarget ex .: LAVSplitter pin VIDEO, I solved my problems.
I want to explain my problem:
My project and developed with DSPack and lazarus.
I have to run a media file playlist and add text scrolling.
Output DeckLink card analog or similar. For connect TV monitor means
S-Video.
Now I see in the videowindow desktop and TV monitors connected to DeckLink, only original videos 720x576.
I want all video formats run. msdn site :
Source and Target Rectangles in Video Renderers
describes how to change rcTarget in videoinfoheader. I do not know how to write in pascal, used dspack. or is there another way to resize video?
I have to build a new filter or I can change properties in rcTarget filter example: LAVSplitter?
my graph
| sourcefile| -> 1920x1080 | LAV Splitter | -> 720x576 | LAV Decoder| -> Tee Filter| -> videowindows and DeckLink render
On the internet many examples to resize external device capture webcam,
i do not find example code external device output.
For this I ask for help.
I have an example for MPEG-2, not working. Where I go wrong?
// var
// mt : AM_Media_Type;
// seqHdr : array [0..0] of byte; //this is right?
// pWIH : MPEG2VIDEOINFO;
ZeroMemory(#Mt, sizeof(AM_MEDIA_TYPE));
Mt.MajorType := MEDIATYPE_Video;
Mt.SubType := MEDIASUBTYPE_RGB32;
Mt.FormatType := FORMAT_MPEG2_VIDEO;
Mt.cbFormat := sizeof(MPEG2VIDEOINFO) + sizeof(seqHdr);
mt.pbFormat := CoTaskMemAlloc(mt.cbFormat);
if (mt.pbFormat = NULL) then exit; // ERROR
ZeroMemory(mt.pbFormat, mt.cbFormat);
{ RCSRC.Left := 0;
RCSRC.Top:= 0;
RCSRC.Right := 0;
RCSRC.Bottom := 0;
}
pWIH.hdr.rcSource.Left:=0;
pWIH.hdr.rcSource.Top:=0;
pWIH.hdr.rcSource.Right:=0;
pWIH.hdr.rcSource.Bottom:=0;
// pWIH.hdr.rcSource := RCSRC;
// pWIH.hdr.rcTarget := Rect(0,0,720,576);
pWIH.hdr.rcTarget.Left:=0;
pWIH.hdr.rcTarget.Top:=0;
pWIH.hdr.rcTarget.Right:=576;
pWIH.hdr.rcTarget.Bottom:=720;
pWIH.hdr.AvgTimePerFrame := 278335;
pWIH.hdr.dwPictAspectRatioX := 4;
pWIH.hdr.dwPictAspectRatioY := 3;
pWIH.hdr.bmiHeader.biSize := 40;
pWIH.hdr.bmiHeader.biWidth := 720;
pWIH.hdr.bmiHeader.biHeight := 576;
pWIH.cbSequenceHeader := sizeof(seqHdr);
CopyMemory(#pwih.dwSequenceHeader, #seqHdr, sizeof(seqhdr));
//-------------------------------------
SourceFilter.FindPin('Output',PinOutSource);
(VideoWindow1 as IBaseFilter).FindPin('Input',PIn_input);
PinOutSource.Connect(PIn_input,#mt);
thank you, thank you,thank you.
I want to use ( 3.Use this Resizer DMO filter ).
I created Resize filter, as your example. OK.
Now I want to use: (FResizerDMO as IMediaObject).SetOutputType for resize my video.
I have difficulty, you can help me?
in site alax.info :
CoCreateInstance the DSP as DMO and add it to DMO Wrapper Filter
Use IWMResizerProps::SetFullCropRegion to initialize the DSP // I do not have to crop region?
Connect input pin
Set output type via IMediaObject::SetOutputType
IGraphBuilder::ConnectDirect output pin
This above is correct?
I write this:
var pVIH :VIDEOINFOHEADER; mt :DMO_MEDIA_TYPE;
ZeroMemory(#mt, sizeof(DMO_MEDIA_TYPE));
mt.majortype := MEDIATYPE_Video;
mt.subtype := MEDIASUBTYPE_RGB32;
mt.formattype := FORMAT_VideoInfo;
// ** I can not translate this **
// VIDEOINFOHEADER * pVIH = (VIDEOINFOHEADER *)pmt->pbFormat;
// pVIH := TVideoInfoHeader(mt.pbFormat^); ????
pVIH.bmiHeader.biWidth := 720;
pVIH.bmiHeader.biHeight := 576;
pVIH.bmiHeader.biXPelsPerMeter:=9;
pVIH.bmiHeader.biYPelsPerMeter:=16;
pVIH.bmiHeader.biSizeImage := 720 * 480 * 3;
hr := (FResizerDMO as IMediaObject).SetOutputType(0,#mt,DMO_SET_TYPEF_CLEAR);
if hr <> S_OK then showmessage('error'); // I receive error
correct this road?
if it is correct you can help because it does not work.