Solved

Access main window class from External Function

Posted on 1998-11-13
2
178 Views
Last Modified: 2013-11-20
hi folks,

   Here is the question:

UINT ComputeThreadProc (LPVOID pParam) {

   // Codes of retrieving window Controls from Main Window

   return 0;
}

   Could anyone send me a sample codes of retrieving window controls (e.g. Edit, Listbox...etc) from the main window or dialog.

Many thanks.

stephen
0
Comment
Question by:stephenkong
  • 2
2 Comments
 
LVL 6

Accepted Solution

by:
thresher_shark earned 50 total points
Comment Utility
What I would do is:

1) As the pParam, send a pointer to a CWnd, or if necessary, a structure that contains a pointer to a CWnd.
2) This CWnd is a pointer to the main window or dialog.  In the thread function, you could then use the pointer to access all of the window's edit controls, list boxes, etc... using, for example, GetDlgItem (...);

Here is an example (like you requested):

// MainWindow contains a pointer to a CWnd
UINT ComputeThreadProc (LPVOID MainWindow)
{ CWnd *mainwnd = (CWnd *) MainWindow;

  // then you can do whatever you want with it, for example:
  mainwnd->GetDlgItem (IDC_EDIT_CONTROL1)->ShowWindow (SW_SHOW);

  return 0;
}

If you have any further questions, please feel free to ask.  Thanks!
0
 
LVL 6

Expert Comment

by:thresher_shark
Comment Utility
Make sure you accept or reject answers at the questions you have asked so far.  It is important to not only ask questions, but also to follow through on them!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Doc'in system (example?) BA 7 78
tripleUp challenge 7 65
sumHeights2  challenge 7 75
wordcount challenge 11 73
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now