Jump to content

JeanCremers

Members
  • Content Count

    26
  • Joined

  • Last visited

Posts posted by JeanCremers


  1. Thanks Remy.

    I'm getting EOSError 'System Error. Code 1411, Class does not exist.'

    This is c++builder 6 🙂

     

    Edit, i also tried 

    
    void __fastcall TAstroClockMainForm::ApplicationEvents1Message(tagMSG &Msg,
          bool &Handled)
    {
    if (Msg.message == WM_APP)
      Application->MessageBox("", "", MB_OK);
    
    }
    
    


    and

     

    
    HWND hwnd = FindWindow("TAstroclockMainForm", NULL);
    if (hwnd)
      SendMessage(hwnd, WM_APP, 0, 0);
    
    

  2. Ok, so one prog does for instance 

    
    HWND hwnd = FindWindow(NULL, "myprog");
    if (hwnd)
      SendMessage(hwnd, WM_USER, 0, 0);
    
    

     

    And what exactly should the other prog do? I have this, but it's not working.

    
    in form constructor Application->HookMainWindow(&AppHook);
    
     
    
    bool __fastcall TMainForm::AppHook(TMessage &Message)
    {
    if (Message.Msg == WM_USER)
      {
    
      Application->MessageBox("", "", MB_OK);
      return true;
      }
    return false;
    }
    

     

    But i'm not getting any msg there.

     

    Thanks.


  3. 1 hour ago, Vandrovnik said:

    If you use type "currency" instead of "double", it would work too and you can avoid most of the conversions between numerical and string types. Currency can keep 4 decimal places (even the 0.1 🙂 ).

    Can't do, i need type double, its for a script language and it has no currency type, but it has double. And this works for my needs.


  4. 8 minutes ago, David Heffernan said:

    Then you are going to need to work out what your problem really is. Because it hasn't been stated here. If you want to work with numbers that have a finite number of decimal digits, then use a decimal type. It is precisely why such things exist.

    I'm ok with my current solution, it does what i need it to do.


  5. 1 hour ago, David Heffernan said:

    Neither. Spawn of satan, should never have been published.

     

    In your case do all the behind the scenes work using integers and then divide by 10 just when you need the actual value. Or use a decimal type like currency.

    🙂

     

    Thanks. I tried the multiply/divide trick, but not with 10 but with 100000 and ran into similar problems. Converting to a string and back to a float at least seems to work against the cumulative issue.


  6. So i thought 0.1 was representable in floating point, obviously not.

    How do i use IsZero() or SameValue in a situation like this.

     

    updownbuttonclick(TObject *Sender, TUDBtnType Button)

    {

    value += (Button == btNext ? 0.1 : -0.1);

    }

     

    What i'm doing now is convert value to a string and then back to fp, this eliminates the cumulative rounding error. How to tackle this with one of those math functions?

     

    Thanks.


  7. Hello,

    I found a strange complier/linker bug. I'm still using bcb 6 but i thought i'd check with c++builder 10.4 and lo and behold, there's the same bug.

    Look at the image, it says it all, the result should be zero but it's not.

    You can see the result in the caption, it's always this number 2.77etc E-17.

    I've also seen it happen with 10 - 0.1 giving 9.911111 or something.

    Man i feel bad, i made my life's work with this.

     

    Please try this yourself.

    2022-11-23_10-35.png

    • Haha 1

  8. It's working great Remy. A progressbar on the testapp to show download progress!

    Your name already was in the credits and again you contributed to my program, many thanks again.

    Good old TeamB, i miss those times, Kent Reisdorph and all.. Does it still exist?

     

    ps, 

    
    void __fastcall OnWorkHandler(void *AData, TObject *ASender, TWorkMode AWorkMode, __int64 AWorkCount)
    
    should be:
    
    void __fastcall OnWorkHandler(TObject *ASender, TWorkMode AWorkMode, __int64 AWorkCount)
    
    

  9. Hi Remy,

    I got it to compile with warnings

    m.Code = handler;
    [bcc32c Warning] ssl.cpp(50): implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension
    
    and..
    
    http->OnWorkBegin = makeEventHandler<TWorkBeginEvent>(&funcs, &MyOnWorkBeginHandler);
    ssl.cpp(72): in instantiation of function template specialization 'makeEventHandler<void (__closure *)(System::TObject *, Idcomponent::TWorkMode) __attribute__((fastcall)), void (void *, System::TObject *, Idcomponent::TWorkMode) __attribute__((fastcall))>' requested here
    
    

     

    That last warning i also get on

     http->OnWorkEnd = makeEventHandler<TWorkEndEvent>(&funcs, &MyOnWorkEndHandler); 

    But NOT on http->onWork

     

    In the test code OnWorkBegin and OnWork are never called. I tried debugging the dll to get an idea what was going on but run to cursor didn't work there, though i used the debug version.

     

    If you want we can call it a day? At least I can use ssl now..

     

    Some funny thing, i could only get one function to export from the dll, if i tried to export only a small 'void mytest(void)' i got a linker error in the test app, though nirsoft's dll export vieuwer shows them allright.

    ps, could it have something to do with indy not living on a form? I tried to assign OnWork etc in the dll to a plain void __fastcall MyOnWork(void *AData, TObject *ASender, TWorkMode AWorkMode, __int64 AWorkCount) in the dll but got an error about incompatible type.


  10. Gives these..

    I've got it working nicely without the events though.

    
    [bcc32c Error] main.cpp(23): static_cast from 'void *' to 'OnWorkBeginFunc' (aka 'void (*)(OnWorkMode, long long)') is not allowed
    [bcc32c Error] main.cpp(24): cannot initialize a parameter of type 'OnWorkMode' with an lvalue of type 'Idcomponent::TWorkMode'
    
    

  11. Hi Remy,

    Getting errors on the lines in the three functions, void(*) vs void(**):

    
    OnWorkBeginFunc func = static_cast<OnWorkBeginFunc*>(ASelf);
    
     
    
    [bcc32c Error] main.cpp(23): cannot initialize a variable of type 'OnWorkBeginFunc' (aka 'void (*)(OnWorkMode, long long)') with an rvalue of type 'OnWorkBeginFunc *' (aka 'void (**)(OnWorkMode, long long)')
    
    


  12. Remy I'm trying to make a dll in c++builder 10.3 to use that Indy version with my application made in c++builder 6.

    Is there a way to export OnWork(), OnWorkBegin(), OnWorkEnd()? How should those functions be declared, Something with TNotifyEvent?

    Thanks!

     

    
     

    #define EXPORT extern "C" __declspec(dllexport)

     

    EXPORT int getdata(char *url, char *data, ???onwork???)
    {
    TIdHTTP *http = new TIdHTTP;
    http->OnWork = onwork; // ??????????????????????????????

    TIdSSLIOHandlerSocketOpenSSL *SSL;
    SSL = new TIdSSLIOHandlerSocketOpenSSL(NULL);
    IdOpenSSLSetLibPath(ExtractFilePath(ParamStr(0)));
    SSL->SSLOptions->Method = sslvTLSv1_2;
    http->IOHandler = SSL;
    http->ReadTimeout = 10000;
    String s = http->Get(url);
    memcpy(data, s.c_str(), s.Length());
    }

    
     

     

    Btw i was getting an error about strcpy() not found, for now i'm using memcpy, probably to do with widechar, still haven't got into unicode that much because of my c++builder 6 code.


  13. Thanks Remy,

    WhichFailedToLoad reported ssleay32.dll, the newer one, but it also reports NULL when i try some other dll's.

    I looked at the WIP code but i don't feel like trying to use it, i'm afraid that i will break something. For now http still works, i'm using indy so my prog can download additional files / updates from my provider, this still works. Another prog i had refuses since awhile, i guess that website had some ssl update. So here's hoping http will keep working...

    ps what's up with all the q,r,s,t,u in the names?

×