Solved

Access main window class from External Function

Posted on 1998-11-13
2
190 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
ID: 1324671
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
ID: 1324672
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 123
MaxSpan challenge 9 96
Dell Alienware Graphics Amplifier Driver for non-Alienware systems 18 258
Problem to event 3 97
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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