Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. sendmessage not sending in VB dll:

sendmessage not sending in VB dll:

Scheduled Pinned Locked Moved Visual Basic
questioncomhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    ns
    wrote on last edited by
    #1

    The VB dll has in a function:

    result = SendMessage(PbarHandle, 1026, 5, 0)

    The VC client sends in the handle of a progressbar. I verfied that handle sent in is being received by the VB dll. However if I put a msgBox right after the SendMessage, it doesnt fire. In the VC client, at the call to the dll, a com error happens:

    void CMswayView::OnButton2() 
    {
    
         try
          {
          CoInitialize(NULL);
    	  _Class1Ptr ptr;
    	  ptr.CreateInstance(__uuidof(Class1));
    	  m_Progress1.SetStep(1);
    
    	  m_Progress1.SetRange(1, 10);
    
    
    		
    		long lHwnd=(long)m_Progress1.GetSafeHwnd();
    		
    		ptr->CheckingStuff(&lHwnd);  //com error happens here
    
          }
          catch(_com_error &e)
          {
           bstrDesc = e.Description();
    
          }
          CoUninitialize();
    }
    

    But we know the error is happening in the VB dll since the we cant get past the sendmessage, and the very next line: msgbox doesnt fire. How can I figure out what is happening? Why is sendmessage not working? Is it that I've done something dumb in sending in the handle and its not valid anymore or something? I have a #import in my VC client for the VB dll. Thanks, ns 1026 is just setting the position. Not even 1029 (PBM_STEPIT) works. Somethigs fundamentally flawed in my assumptions here...

    M 1 Reply Last reply
    0
    • N ns

      The VB dll has in a function:

      result = SendMessage(PbarHandle, 1026, 5, 0)

      The VC client sends in the handle of a progressbar. I verfied that handle sent in is being received by the VB dll. However if I put a msgBox right after the SendMessage, it doesnt fire. In the VC client, at the call to the dll, a com error happens:

      void CMswayView::OnButton2() 
      {
      
           try
            {
            CoInitialize(NULL);
      	  _Class1Ptr ptr;
      	  ptr.CreateInstance(__uuidof(Class1));
      	  m_Progress1.SetStep(1);
      
      	  m_Progress1.SetRange(1, 10);
      
      
      		
      		long lHwnd=(long)m_Progress1.GetSafeHwnd();
      		
      		ptr->CheckingStuff(&lHwnd);  //com error happens here
      
            }
            catch(_com_error &e)
            {
             bstrDesc = e.Description();
      
            }
            CoUninitialize();
      }
      

      But we know the error is happening in the VB dll since the we cant get past the sendmessage, and the very next line: msgbox doesnt fire. How can I figure out what is happening? Why is sendmessage not working? Is it that I've done something dumb in sending in the handle and its not valid anymore or something? I have a #import in my VC client for the VB dll. Thanks, ns 1026 is just setting the position. Not even 1029 (PBM_STEPIT) works. Somethigs fundamentally flawed in my assumptions here...

      M Offline
      M Offline
      Matt Philmon
      wrote on last edited by
      #2

      Show me how you declared SendMessage (hint: in VB6 you used Long for Window Handle. In VB.NET you need to use Integer)

      N 1 Reply Last reply
      0
      • M Matt Philmon

        Show me how you declared SendMessage (hint: in VB6 you used Long for Window Handle. In VB.NET you need to use Integer)

        N Offline
        N Offline
        nss
        wrote on last edited by
        #3
        Private Declare Function SendMessage Lib "User" (ByVal hWnd As Long, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Long) As Long
        

        I changed it to ByVal hWnd As Long, it was originally integer from the msDN. But it still doesnt work.....:confused::confused: The msgbox doesnt fire,

                       result = SendMessage(pBAr, 1029, 0, 0)
                       
                       MsgBox result   /// never fires
        

        The VC client gets a com error at runtime (goes into the catch(com e) block) is:

        sway.exe (KERNEL32.DLL): 0xC000008F: Float Inexact Result.

        Desperate!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups