Jump to content

alogrep

Members
  • Content Count

    157
  • Joined

  • Last visited

Everything posted by alogrep

  1. I need help again with pngimage. I have some custom control containing a Tpicture. The Pictures were loaded as TpngObject. I was told (Uwe Raabe) that if I load and then save the form containing the controls, they would be saved as Tpngimage. Or maybe I misunderstood. The problem is that the picture graphic is not loaded at all in the dfm. If I inspect the dfm in Delphi IDE it does not have the line Glyphs.Glyph.Data = { at all (glyphs,glyph is the Tpicture.). If I inspect with with Notepad I see Glyphs.Glyph.Data = { 0A54504E474F626A65637489504E470D0A1A0A0000000D494844520000004E00 00004E08060000008EAA201D000020CD4944415478DAED9C079414759EC7BFD5 69BA7B72C etc. However, if I do not save the dfm, at run time the image in Glyphs,Glyph is shown, although at design time is not present in the dfm. I am totally lost, I tried to remove all TpngObject reference from the project, but nothing changed. Can anyone help? How can I save the pngobject in the controls to the Vcl.Imaging.pngimage.TPngImage?
  2. alogrep

    WMI (winspool) and critical section

    HI. Is accessing WMI thread safe? I mean this: I my Thread repeatedly list the print jobs in the sn spool with this code FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); FWMIService := FSWbemLocator.ConnectServer('localhost', 'root\CIMV2', WbemUser, WbemPassword); FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM Win32_PrintJob','WQL',wbemFlagForwardOnly); oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant; etc. ...... Do I need to protect that with a criticalsection Acquire/Release? Thank you
  3. alogrep

    WMI (winspool) and critical section

    Thanks. It seems then I do not need to use a critical section because each thread instantiate the object and use the service.
  4. alogrep

    WMI (winspool) and critical section

    Yes, there other ways, but they do not work Anyway, in EACH thread I have a funtcion that does this FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); FWMIService := FSWbemLocator.ConnectServer('localhost', 'root\CIMV2', WbemUser, WbemPassword); FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM Win32_PrintJob','WQL',wbemFlagForwardOnly); oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant; etc. ...... My question is: do i need to encapsulatwe it in a critical section Acquire/Release?. ( I am rather new to threads, but I would think it is not necessary)
  5. Hello. This is a hard one for me to understand/solve. Using synapse on delphi 11. I have a main form that starts a thread (TTCPHttpDaemon) defined in a used Unit; TTCPHttpDaemon.create; The initialization section of the the blcksock.pas of sinapse, runs at the very beginning of the App seems to successfully create the socket synsock.WSAStartup(WinsockLevel, WsaDataOnce); I create the thread (log_it() is a function to log messages). TTCPHttpDaemon.Create; TRY inherited create(false); sock:=TTCPBlockSocket.create; FreeOnTerminate:=true; except on E:SysUtils.Exception do begin log_it('TTCPHttpDaemon.Create '+e.message); end; end; end; No errors. Then right here i get the inexplicable behaviour procedure TTCPHttpDaemon.Execute; begin with sock do begin try CreateSocket; except on E:SysUtils.Exception do begin log_it(e.message); end; end; bind(serverip,PORTNUMBER); //portno listen; repeat try b:= canread (1000); RIGHT HERE!!!!! except on E:SysUtils.Exception do begin log_it('****** Canread error: '+e.message); end; end; if b then ClientSock:=sock.accept; ................... on the canread() function the error is 'winsock not initialized' code:10093 And the main form is destroyed, by-passing the except block. What goes wrong, where? This happened suddenly without any change to the App that I could tell. Could it be one of the lates windows 10 updates?
  6. Thanlks Remy. Ah! Fool that I am!. I caused the problem. It is true that the App had not changed at all when this started to happen. But the condition of the data that the app reads had changed in these last few occasions. In short, I have a check function that if the result is negative it goes Application.terminate. This a couple of lines before the Thread>create(); Obviously the app continued for a few microseconds and the thread was created BUT when it got to the Execute part the application was terminated and the socket was closed. I rewrote the lines if not checked then begin Application.terminate; exit; end;
  7. alogrep

    Error when printing fromThread

    Hi I have an httpserver (synapse), which among other things print a short but rather complex . report. Therefore in the Execute part I have put a Critical section Acquire;/Release block (when rinting is required.) I cannot use a Printer:=Tprinter.create in the Execute block because the report creation and printing functions are used also by external EXE (and I cannot figure out to tell the function for the report to use th Printer created inside the thread or the vcl global Printer when it is called by gh external program). After I print a few times i get this error First chance exception at $75B98FC2. Exception class EAccessViolation with message 'Access violation at address 671A7B65 in module 'madExcept32.dll'. Read of address 8BF455D7'. Process Posserver.exe (2480) Is this an error of madexcept of of my program? And if it is from my program would anybody have an idea as ti what i am doing wrong and how to fix it? I hqve attached the log of the entire error message. log.txt
  8. alogrep

    Error when printing fromThread

    I do not do anything that requires user intervention inside the Thread. I guess you were misguided by the "PayForm_UNIT". I named it so for mnemonic reasons, but is a UNIT not a FORM. Anyway I guess I found the problem (I used a printer handle that was freed and not set to NIL).
  9. alogrep

    Error when printing fromThread

    The problem seems to be that Thread ID: 16172 that I do not now where it comes from IN the log of the Thread.Execute it dows now show (I log every threadId with GetCurrentThreadid()). Thread Start: Thread ID: 980. Process Posserver.exe (13768) Thread Start: Thread ID: 16172. Process Posserver.exe (13768) Thread Exit: Thread ID: 16172. Process Posserver.exe (13768) Module Load: PRNFLDR.dll. No Debug Info. Base Address: $53A00000. Process Posserver.exe (13768) Module Unload: PRNFLDR.dll. Process Posserver.exe (13768) Thread Exit: Thread ID: 980. Process Posserver.exe (13768) First chance exception at $76D98FC2. Exception class EAccessViolation with message 'Acc...... The proper way should be is like this: Thread Start: Thread ID: 812. Process Posserver.exe (13768) Module Load: PRNFLDR.dll. No Debug Info. Base Address: $53A00000. Process Posserver.exe (13768) Module Unload: PRNFLDR.dll. Process Posserver.exe (13768) Thread Exit: Thread ID: 812. Process Posserver.exe (13768) But then that Thread ID: 16172 gets in the way and messes things up.
  10. alogrep

    Error when printing fromThread

    This is the relevant code. code.txt
  11. alogrep

    Error when printing fromThread

    Thcode.txtcode.txtanks. It's quite a long code. I triend to avoid tall unnecessary lines...
  12. HI. I am trying to figure what the 2 items indicated by the red lines mean. Is there a list of each element of the database definition? Or any other suggestion?
  13. Hello everybody. Another one of my misteries . I have created a component Tslim(TComponent); It is basically a table with cells and row that are created dynamically. In a particular procedure that creates new cells and rows, something happens that suddenly the Slim becomes NIL. That is in a try… except block, when the exception is raised, I inspect the value of Slm, and it shows NIL. The Slim.Destroy is not triggered. Is the a way or something (an Event?) that could be triggered the moment this happens so I can find out what exactly causes that?
  14. What I don’t understand is: how come the G variable is set to NIL? From what I have seen if an object is destroyed for say AV, it is destroyed but not set to NIL. A to send more code, it is not feasible because is too long and nobody would take the time or have the patience to read it. I can give the “scheme” I use.. type tgrids=record g1,hgrid,tabgrid,extras,extragrid,groupqty,servgrid,all,mitad1,mitad2:Tslim; end; type OrderLinevars = record grids: Tgrids; myCompname_,pass, curtabtrans:string // and a bunch of other variables; end; type orderlinerec = record id: string; orderline: OrderLinevars; end; type orderlinearr= array of orderlinerec; PtRecord=^OrderLinevars; in main form I have this public orderlines : orderlinearr; TTCPHttpThrd = class(TThread) private Sock:TTCPBlockSocket; orderline: PTREcord; thisip,objs: string; ......... When there is a new POST request, a new thread is created and executed/ in the Execute part, as the first thing, I do FOR N:=0 TO HIGH(MAIN.ORDERLINES) do if (MAIN.orderlines[n].id=thisip) then begin orderline:=@MAIN.orderlines[n].orderline; orderlineindex:=n; break; end; if orderlineindex<0 then begin setlength(main.orderlines,length(main.orderlines)+1); orderlineindex:=high(main.orderlines); MAIN.orderlines[orderlineindex].id:=thisip; orderline:=@MAIN.orderlines[orderlineindex].orderline; end; The "orderline" is used (for brevity) in all calculations inside the execute. I need some variables that are part of the orderlinerec -> OrderLinevars to be persistent; All the grids are set to NIL at the beginning of Execute, freed at the end; For example, a POST requests set some variables that I need to re-use later for another POST request from the same user. Just as lost as before.
  15. I found where the problem occurs (see apptached image). However the call stack doesn't go inside the procedure where the problem actually happes. This is the code procedure (g:Tslim; html:string); var c,r: integer; begin C:=0; R:=0; WITH G DO // this is the "slim" component while (HTML <> '') and (html <> ';') and (copy(html,1,5)<>'slim:') DO BEGIN try N:=POS('<col',html); if n>0 then begin if c> colcount-1 then colcount:=c; if alreadytranslated then begin if (g=extras) and (c=0) and (r>0) and (copy(html,1,5) <> _nota) then cells[c,r]:=' '+copy(html,1,n-1) else cells[c,r]:=copy(html,1,n-1); end else if (g=extras) and (c=0) and (r>0) and (copy(html,1,5) <> _nota) then cells[c,r]:=' '+Fromspanish(copy(html,1,n-1)) else cells[c,r]:=FromSpanish(copy(html,1,n-1)); system.delete(html,1,n+3); if (g=extragrid) and (c=0) then begin k:=pos('line-through',html); if (k>0) then begin orderline.disabledrows[r]:=true; system.delete(html,k,12); end; end; n:=pos('color:::',html); if (n=1) then begin if (copy(html,9,4) <> 'null')then begin if copy(html,9,1) ='#' then begin cellcolors[c,r]:=HexcolToTcolor(copy(html,10,6)); system.delete(html,1,15); end else begin cellcolors[c,r]:=HexcolToTcolor(copy(html,9,6)); system.delete(html,1,14); end; end else system.delete(html,n,12); end; k:=pos('<row',html); if k=1 then begin system.delete(html,1,k+3); c:=-1; // inc() below to 0 inc(r); if r> rowcount-1 then rowcount:=rowcount+1; kount:=rowcount; end; inc(c); end else break; EXCEPT showmessage(inttostr(c)+' '+inttostr(r)+' '+sparam); END; end; end;
  16. alogrep

    DsPack for Delphi 11?

    Hi. Does anybody know where to find the Dspack packages for Delphi 11? Thank you in advance.
  17. alogrep

    DsPack for Delphi 11?

    Thanks.
  18. HI. I am totally new to multi platform apps, hence I can't make head or tail of what the error may mean. I hope somebody could give me some help. I downloaded a sample app from Github. When I build it for Windows, it is succesfull. When I bild it for Android I get the error: [PAClient Error] Error: E7688 Unable to execute '"C:\Program Files\AdoptOpenJDK\jdk-8.0.242.08-hotspot\bin\java.exe" -cp "c:\program files (x86)\embarcadero\studio\22.0\bin\Android\r8-3.0.73.jar" com.android.tools.r8.D8 --release --min-api 23 --output "C:\HMXE_A\multi_Platform_samples\01-HelloWorld\Android64\Debug\HelloWorld.classes" @"C:\HMXE_A\multi_Platform_samples\01-HelloWorld\Android64\Debug\dex_list.txt"' (Error 1) Delphi Alexandria.
  19. alogrep

    custom fonts and sizes showmessage()

    HI. Is it possible to change font and button sizes in the showmessage() function? (Delphi 11.2)
  20. alogrep

    custom fonts and sizes showmessage()

    HI dummzeuch. "Changing the standard ShowMessage dialog in any way (different font etc.) will negate these advantages.". I do not want to negate those advantages, but as it is the dialog appears too small in higher resolutions. I would like to resize font size according to the screen resolution so that it would appear the same on any resolution.
  21. I have a pre XE app that for 15 years printed all right. The app prints tickets to Epson printers on a LAN. The printers are set up to auto-cut (they stop printing and cut the page after the last line is printed). I recompiled the app to Delphi 11.2 and all works fine, including the printing. But after a day and ½ of operations (not continually, the network is shut down at night) a strange Outcome came to life: the printer did not cut the paper after the last line printed, but continued up to, presumably, the default page length, leaving a long, long white page empty Anybody would have any idea where to start looking into?
  22. alogrep

    LAN network printer page cutting changes mysteriously.

    Thanks, Stano. But the PC on the LAN did not change. The only thing that changed is the EXE: before was a Delphi 7 compiled EXE, now is a Delphi 11.2 compiled. Do you suspect that the new EXE compiled on a Windows 11 with delphi 11 could have some miscomunication with the pre-existing driver (for Windows 7)? Finally the weird thing is that it worked ok fot a day and 1/2. then the problem arose. I re-installed the old EXE and it printed ok. When I went back to the delphi 11 EXE, it printed ok too (so far).
  23. Hi. I get the subject error on this line of code SetWindowLong(thisform.Handle, GWL_STYLE, WS_POPUP or WS_CLIPSIBLINGS or WS_CLIPCHILDREN or WS_SYSMENU); The peculiar thing is I get it in one application but not in another application (they both use the identical code and "thisform") I traced it with Ctrl+F7 and this is the sequence that produces th error. Any help, please? SetWindowLong(thisform.Handle, GWL_STYLE, WS_POPUP or WS_CLIPSIBLINGS or WS_CLIPCHILDREN or WS_SYSMENU); function TWinControl.GetHandle: HWND; begin HandleNeeded; Result := WindowHandle; end; procedure _BoundErr; {$IFDEF PUREPASCAL} begin ErrorAt(Byte(reRangeError), ReturnAddress); end; {$ELSE !PUREPASCAL} {$IFDEF CPUX86} asm MOV AL,reRangeError JMP Error end; procedure Error(errorCode: TRuntimeError); begin ErrorAt(Byte(errorCode), ReturnAddress); end;
  24. alogrep

    Range check error (10016) on SetWindowLong

    Thanks, Remy. It worked.
  25. HI. Delphi 11.2, windows 10. I tried to build webbrowser.dproj found in C:\Users\Public\Documents\Embarcadero\Studio\22.0\Samples\Object Pascal\Mobile Snippets\WebBrowser but I get that error. I tried to put C:\Program Files (x86)\Common Files\Oracle\Java\javapath (where my java.exe resides) in the path, but had no succes. Could someone help, please?
×