|
With the exception of the desktop, all windows are a child window. So if you already have a handle to the window of interest, you can use FindWindowEx() like:
FindWindowEx(hWnd, NULL, class_name, NULL); You can find out what goes in place of class_name by using Spy++. Just open up the window having the control you want to meddle with and use Spy++ to get the control's class name.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
c121hains wrote:
But i'm looking for controls within a child window
those controls are child windows (of the child window). I haven't used it for a while, but IIRC, you use FindWindowEx(), sending in a null as it's parent window. Find the child this time using it's parent window as one of the arguments, then find a child of that window (the controls you're talking about) by sending in it's parent as one of the arguments. get it?
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
ahh i see! ok Thanks.
I used a program called WinDowse and when i place the cursor over the (what looks like a Rich Edit box) turns out to have the class name "DimensionEdit"!
Another control used in MS Enterprise Manager is "DimensionDataCtrl".
If i want to send any messages to these controls (child windows), I have to know what messages they are listening to. So far i can't find any information on DimensionEdit class. Could they have created their own class by inheriting a rich edit box?
|
|
|
|
|
The class that i want (DimensionEdit) is within a class called "#32770" and that itself is within a "#32770" which lies within the base "MMCMainFrame" window.
Everytime I run
HWND hWnd = FindWindowEx(enterprise->m_hWnd, NULL, "#32770", NULL);
It fails to bring up the correct handle! Entering in the description of the window doesn't work either.
Please help!
|
|
|
|
|
c121hains wrote:
The class that i want (DimensionEdit) is within a class called "#32770"...
This is the standard dialog box class.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
So.. are you saying that this would work:
HWND hWnd = FindWindowEx(enterprise->m_hWnd, NULL, "CDialog", NULL);
..but in Spy++, the name of the class is #32770. If it's a dialog class, how come the order of window controls is:
- DimensionEdit
- #32770
- #32770
- MMCEnterprise Manager Main Window
When i'm looking at it, it is
- Some edit box within a tab order control within a dialog box window all within the main Enterprise Manager window. (
|
|
|
|
|
c121hains wrote:
HWND hWnd = FindWindowEx(enterprise->m_hWnd, NULL, "CDialog", NULL);
Don't confuse C++ classes with window classes (those registered with RegisterClass() ).
See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I managed to finally get it working. I had to first grab the handle to the desktop and use GetNextWindow through about 200+ handles to get the one matching the partial window text that i was looking for. The dialog's window text that i wanted contained static and dynamic text. That was why i couldn't just find the window with just he window's text.
Thanks for the help!
|
|
|
|
|
Once you had the handle to the dialog itself, couldn't you then have used GetDlgItem() to get the handle to the control without having to enumerate through each control on the dialog?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I didn't need to. I know the class name in the dialog that i need. The problem was getting the handle to the dialog itself. I had to enumerate through the all handles at the sub desktop level.
|
|
|
|
|
I am trying to ead data from a text file using fscanf, but everytime the program reaches the fscanf line it comes up with First-chance exception at 0x77f62992...: Access violation reading location...
If anyone can help please let me know. If you need the exact program lines let me know and I will post them.
simaneal
|
|
|
|
|
simaneal wrote:
If anyone can help please let me know.
I'm having difficulties seeing your monitor from here. Can you show us what your code looks like?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
It's usuallly a mismatch between the formatting string and the paramters since there are no checks on these.
As David mentioned, including the line of code in your message would help.
Elaine
The tigress is here
|
|
|
|
|
Here is the section of my code with the fscanf that is giving me the problem. It is part of a fuction called from the main program. The program will print starting scan and then it comes up with the exception.
int yinitial;
printf("starting npv in npvpixel");
FILE* agefile;
printf("agefile set");
int inita=0;
int inage;
int list[118];
int time1;
int zc=0;
printf("initialized in npvpixel");
/*if ((inage = (short int*)malloc(array_size * sizeof(short int))) == NULL) {
(void)printf("ERROR: Malloc failed");
(void)exit(EXIT_FAILURE); */ /* or return EXIT_FAILURE; */
/*}*/
printf("malloc ok");
/*inage= (int*)malloc(ycoor*sizeof(int));*/
time1=0;
float npv1a=0.0;
for(zc=1; zc<21;zc++)
{
printf("opening file");
if (zc==1){
if ((agefile=fopen("c:\\stinit.txt","r"))==NULL){
printf("can not open initial file");
}
else{
printf("initial age file open");
/* Set pointer to beginning of file: */
fseek( agefile, 0L, SEEK_SET );
printf("start of file found");
for (yinitial=0; yinitial
|
|
|
|
|
simaneal wrote:
inita = fscanf( agefile," %d", &inita );
This looks odd. If you even need it, you should store the return value from fscanf() in a separate variable.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
sorry,
I have tried all kinds of things to work.
That line should be
fscanf( agefile," %d", &inita );
The file for the data is opened as agefile and the data should be stored in &inita.
simaneal
|
|
|
|
|
simaneal wrote:
fscanf( agefile," %d", &inita );
Is the space preceding the %d intentional?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
The space was not intentional, but removing it did not change the outcome. I am using Visual Studio as my compliler and when it hits the exception and I have the program break it returns to to a write.c code. Any ideas why and what does write.c do when I am inputting data?
If you would like to see where in write.c it breaks to let me know and I will post it.
simaneal
|
|
|
|
|
Seeing what happens in write.c is not nearly as important as the layout of the file being read. Can you scale the problem down to just a few lines of code and a very small input file?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I have a scaled down version that only reads and prints the data. This "mini" version does not produce the exception that the version in the large program does. I copied the mini version into the large program and the exception reappears. I have tried adding parts of the large program to the mini version to discover what part of the large program is causing the fscanf error, but I have not had any luck so far. Any ideas?
here is the mini version
#include <stdio.h>
const int yc = 10; // Just use some value
void test() {
int yinitial;
printf("starting npv in npvpixel");
FILE* agefile;
printf("agefile set");
int inita=0;
int inage;
int time1;
int zc=0;
printf("initialized in npvpixel");
time1=0;
float npv1a=0.0;
/*goes through all 20 age groups*/
/* for(zc=1; zc<21;zc++) { */
printf("opening file");
//if (zc==1){
/*opens file only when first age group is called*/
if ((agefile=fopen("c:\\stinit.txt","r"))==NULL){
printf("can not open initial file"); }
else {
printf("initial age file open");
/* Set pointer to beginning of file: */
fseek( agefile, 0L, SEEK_SET );
printf("start of file found");
/*allows access to all values in file*/
for (yinitial=0; yinitial
|
|
|
|
|
simaneal wrote:
I have tried adding parts of the large program to the mini version to discover what part of the large program is causing the fscanf error, but I have not had any luck so far. Any ideas?
Which implies that both the mini program and the large program are now identical. Yes? If not, then there are still parts of the large program yet to be added.
As a side note, when posting code snippets, surround them with
tags and use the Preview button. While the compiler does not mind, reading code that is all left-aligned is painful.
<hr><p align="right"><small>"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown</small></p>
|
|
|
|
|
The entire program including its two functions, both
of which use fscanf is over 2500 lines long. I have
tested parts separately in mini programs to make sure
they work and to check that they are doing what I want
correctly. Unfortunately not all the parts want to
work together.
What order would you suggest I add things to the mini
program since it is part of a function called by the
main program? Should I create a stripped down mini
main and build the function completely then build up
the main again?
I am at a loss as to why the mini would work, but not
when added to the rest of the program.
simaneal
|
|
|
|
|
simaneal wrote:
I am at a loss as to why the mini would work, but not
when added to the rest of the program.
This tells me that whatever code has not been added to the mini program is suspect.
You could also take the larger program and remove pieces of it until it starts working.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Playing around with the mini program some more I discovered that changing
fscanf( agefile,"%d", &inita );
to
fscanf( agefile,"%d", inita );
produces tha same erroras the full program.
Any ideas on what I should look for in the full program?
When is the & needed?
simaneal
|
|
|
|
|
simaneal wrote:
When is the & needed?
See here. Notice that the optional arguments (those after the format string) are locations, not values. That is why you must use the address-of (&) operator.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|