Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6648659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:40:53+00:00 2026-05-26T00:40:53+00:00

I have asked two questions earlier about this and for each post there was

  • 0

I have asked two questions earlier about this and for each post there was some solutions i tried them, but the problem still exist.

My first question was : why a windowless Activex does not return the Handle. the suggestion was "change the creation setting an make windowless activate off, i have tried it but still m_hWnd property has returned zero as GetSafeHwnd() method has did.

the second one was the same question this one focused on COleControl class and it’s ancestor CWnd. the solution was as this "Create invisible window somewhere in your control initialization code. Handle the messages sent to this window, and call controls methods directly". so i did that but the created class still returns zero handle.

here is my new invisible class source:

// moWind.cpp : implementation file
//
#include "stdafx.h"
#include "PINActive.h"
#include "moWind.h"
#include "include\xfspin.h"
#include <math.h>
// moWind

IMPLEMENT_DYNAMIC(moWind, CWnd)

moWind::moWind(){}

moWind::~moWind(){}

//=============================================================
LRESULT moWind::OnExecuteEvent (WPARAM wParam, LPARAM lParam)
{
    WFSRESULT *pResult = (WFSRESULT *)lParam;
    CString EK=_T("");
    CString str;
    int reskey=0;
    if (pResult->u.dwEventID=WFS_EXEE_PIN_KEY)
    {       
        LPWFSPINKEY pressedkey;
        pressedkey=(LPWFSPINKEY)pResult->lpBuffer;

    reskey = log10((double)pressedkey->ulDigit) / log10((double)2);

        EK.Format("%d",reskey);
        xfsOnKeyEvent->OnKeyRecieved(reskey);
    }
    else
    {
        str.Format("ExecuteEvent:  ID = %d\r\n", pResult->u.dwEventID);
    }
    MessageBox("a Execute message Recieved");
    return 0;
}
    
BEGIN_MESSAGE_MAP(moWind, CWnd)
        
    ON_MESSAGE(WFS_EXECUTE_EVENT,OnExecuteEvent)
    
END_MESSAGE_MAP()

and this is .h file of the class:

// moWind.h
class IXFSEvents
{
protected:
    IXFSEvents(){};
    virtual ~IXFSEvents(){};
public:
    virtual void OnKeyRecieved(int key)=0;
};

class moWind : public CWnd
{
    DECLARE_DYNAMIC(moWind)

public:
    moWind();
    virtual ~moWind();
    void Register(IXFSEvents* obj)
    {
        xfsOnKeyEvent= obj;
    }
protected:
    IXFSEvents* xfsOnKeyEvent;
    LRESULT OnExecuteEvent (WPARAM wParam, LPARAM lParam);
    DECLARE_MESSAGE_MAP()
};

and at the end here this the way I’ve used this class in my Activex:
in the myActivex.h file:

include "moWind.h"

class CmyActivexCtrl : public COleControl, public IXFSEvents
{
...
Class definition
...
protected:
      moWind tmpWind;
 .
 .
 };

finally in the creation method of myActivex i have initialized the component callback method an wanted to get it’s Handle as this:

CmyActivexCtrl::CmyActivexCtrl()
{
    InitializeIIDs(&IID_DmyActivex, &IID_DmyActivexEvents);
    tmpWind.Register(this);
    myOtherComponent.WindowsHandle=tmpWind.GetSafeHwnd(); //here my Cwnd derived class returns zero
        //my other component gets the handle and call an API with it to register 
        //the given handle and force the API to send the messages to that handle.
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:40:54+00:00Added an answer on May 26, 2026 at 12:40 am

    As you mentioned you need a window handle to be able to receive user messages through it, you always have an option of creating a helper window, such as message only window, see Using CreateWindowEx to Make a Message-Only Window.

    For your windowless control it is okay to not have any window handle at all, so you cannot really rely on handle availability unless you own a window yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have previously asked two questions Question 1 and Question 2 but there is
Questions similar to this have been asked all over, but I haven't been able
I see some related questions have been asked, but they're either too advanced for
I know questions like this have been asked numerous times, but not quite this
Several questions have been asked about the SIFT algorithm , but they all seem
I have asked in two earlier questions to place multiple markers from a XML
This question is related to two different questions I have asked previously: 1) Reproduce
I have inherited some HTML code and have been asked to align the two
I have asked this before but I didn't get the question right so the
This is an extension of an earlier questions I asked, here: Django - Parse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.