|
call Document's UpdateAllViews()
There is no spoon.
mail
|
|
|
|
|
Hi
U can call updateAllViews() which calls the update function which we have added.
I do hope this may help you.
Sujan
|
|
|
|
|
Thats true. But my code flow is like this.
All i have created is an MDI application of the following.
class CComputeApp : public CWinApp
class CComputeView : public CEditView
class CComputeDoc : public CDocument
1. I haven't coded anything on File open / save / close.
2. Everything is taken care automatically.
3. Imagine a file named compute.txt is opened in my application.
4. And after that, I run a process (thats a different class) from CComputeApp.
5. And the process returns a string (contains the filename).
6. Using the string, i call CDocument* CComputeApp::OpenDocumentFile(LPCTSTR lpszFileName) to open the file.
7. The problem is, if the file is already opened, this OpenDocumentFile method doesn't call CComputeDoc::OnOpenDocument(LPCTSTR lpszPathName).
8. And so, the view is not updated.
This is where my problem is. And thats why, i was curious about the place of code.
Sorry for all the frustrations. And hope that, i would overcome this problem.
Again, I thank in advance.
thanx
mughi
|
|
|
|
|
hi all,
I am doing MFC Project..There is a Dialog to LOG ON to the Program.If any one enter user name & password & click "SIGN IN" Button ,I want to display a Dialog Box with "WAIT" Text until the usename validate.
So How do I add wait dialog using Threads or some thing else?
please help me
thanks..
|
|
|
|
|
Hi
You @ VC++ components there is a component called "Splash screen". You can use this / U will get some idea on looking @ that class.
Hope this helps you
SUjan
|
|
|
|
|
hi,
thank u very much.But do u know that how do we do it using Threads?
|
|
|
|
|
Hi
Create a worker thead call the showing code and once the process is over kill the thread. Again sometimes kill the thread may be a problem. I think.
Sujan
|
|
|
|
|
Create a CDialog with text "waiting". DoModal() this dialog.
When the validation is over ::SendMessage(gh_WaitDlg,WM_CLOSE,NULL,NULL);
to close the waiting dialog.
For this your validation should be from a different thread and that thread should have a handle to the waiting dialog.
There is no spoon.
mail
|
|
|
|
|
Using POSIX pthreads, implement the finite buffer consumer/producer code on chapter 5 slide 51. The buffer size is 10, and stores integers. The producer producers the values from 1 to 100 and puts them in the buffer. The consumer removes them and prints them as they are removed.
The program should compile and run on Unix.
aravind
|
|
|
|
|
I can send you the source code for the program for chapter 5, slide 50. Will that do? My program was rated very highly by Consumer Reports, but I don't know about the producer part.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
nivsah wrote:
chapter 5 slide 51
You don't seriously expect us to do your homework for you, do you?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I have a help file that I wrote and saved as a .pdf file. I want to be able to click a help button and have the file pop-up in Acrobat reader. I have coded a system command as follows:
system("start help.pdf");
and this works but it is slow and always pops up a DOS command window. Is there a better way to do this?
|
|
|
|
|
use the windows shell: ShellFileExecute
|
|
|
|
|
Can use ShellExecuteEx / ShellExecute. Have a look @ MSDN
|
|
|
|
|
Thanks, this works great!
|
|
|
|
|
Hi all,
I am relatively new to api programming.I am trying to automate a process and am using EnumWindows to get all window handles. I am then using GetWindowText and strcmp to check which of the window handles corresponds to the relevent window. However it doesnt seem to work i.e., it doesnt simulate the push of the button....
I have pasted the code snippet below.. Any suggestions on how to resolve this will be terrific.
In the main program i have
EnumWindows((WNDENUMPROC) WinCallback, 0);
My function is:
BOOL CALLBACK WinCallback(HWND win, LPARAM nadda)
{
char temp[512];
GetWindowText(win, temp, 512);
printf("%s",temp);
if(!strcmp(temp,"RBNal_Optocomm"))
{
HWND hcomm = FindWindowEx((HWND) win,NULL,"BUTTON","COM 1");
LRESULT lResult2;
lResult2 = SendMessage((HWND) hcomm,(UINT) BM_CLICK,0,0);
return FALSE;
}
}
Please let me know of any suggestions.
D
|
|
|
|
|
BM_CLICK message will fail if the window that will recieve the is not active. Try the code below.
if(!strcmp(temp,"RBNal_Optocomm"))
{
HWND hcomm = ::FindWindowEx((HWND) win,NULL,"BUTTON","COM 1");
if (hcomm)
{
::SetActiveWindow(hcomm);
LRESULT lResult2;
lResult2 = ::SendMessage((HWND) hcomm,(UINT) BM_CLICK,0,0);
return FALSE;
}
}
|
|
|
|
|
Thanks.. It still isnt working though.. I have passed an LPARAM value of 0 into the function.. Would this matter??
D
|
|
|
|
|
Hi,
try calling SetActiveWindow(win) before the line SetActiveWindow(hcoom). It should look like this
if (hcomm)
{
::SetActiveWindow(win);
::SetActiveWindow(hcomm);
LRESULT lResult2;
lResult2 = ::SendMessage((HWND) hcomm,(UINT) BM_CLICK,0,0);
return FALSE;
}
I had tested this and i had sent a sample applications (sender and receiver) in your email.
|
|
|
|
|
Hi
Thanks.. it worked....
Deepak
|
|
|
|
|
Hi all,
here is some interesting problem.... the problem setup goes like this...
a plane paper is placed on a table and a sphere is placed over it at some height and on that sphere at certain height a light was placed.
Noow as we all know it produces a shadow on the paper which will be some what elliptical if the light is not on the center line of the sphere. In this condition if we assume the paper as a 2D image then how can we calculate the pixels tht are covered under the elliptical shadow ( or to put it in other way while scannin form top how can we decide whether a pixel falls under the shadow).
any ideas ot thoughts are appreciated.
thanks in advance,
Suman
|
|
|
|
|
Google ray tracing.
Or DirectX will do it for you, if that's all you need.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
the shadow is the intersection of the plane of the paper and the cone whose apex is at the light and whose sides are tangent to the sphere.
The distance from apex (light) to center of sphere is the hypotenuse of a triangle whose side opposite the apex angle is the radius of the sphere. This is enough to determine the cone.
|
|
|
|
|
Hi Scott,
yep u r right....i understood ur point. But the problem is how to tell whether a pixel lies in the shadow or not. I mean r there any techniques or approach to find it out.
becos i was given a sphere of some radius and the height at which it is and the pixel at which the center of the sphere lies. and i have to figure out all the pixels covering under its shadow...and then i have to do some other calcualtins for those pixels... but first of all i have to find those pixels.
hope i am clear to u.
thanks in advance,
Suman
|
|
|
|
|
Dear sirs:
I am learning VC++ and am having trouble compiling my project. The project includes several classes that inherit properties from other classes. I ran into just 3 "unresolved external symbol errors - LNK2019".
I am using the Visual Studio .NET 2003 platform to develop the application with. I have included the source files with this post and you can recreate the project by creating a new Win32 Console Application project named "use_student", and simply add the files into your project.
Any help would be much appreciated!
Thank you,
Rob Hyland
NOTE: if you just see a line of code that says "#include" all by itself it should read
"#include (bracket symbol) iostream (bracket symbol)"
***************************************************************************************************
*********************************** Header Files **************************************************
//
//////////////////////////////////////////////////////////////
// Listing 13.3 studentc.h. /
// studentc.h -- defining a Student class using containment /
//////////////////////////////////////////////////////////////
//
//
#ifndef _STUDNTC_H_
#define _STUDNTC_H_
#include <iostream>
#include "arraydb.h" // -- ArrayDB objects.
#include "strng2.h" // -- String objects (from Chapter 11).
using namespace std;
class Student
{
private:
String name;
ArrayDb scores;
public:
Student() : name("Null Student"), scores() {} // -- Use initialization syntax to init. objects.
Student(const String & s) : name(s), scores() {}
Student(int n) : name("Nully"), scores(n) {}
Student(const String & s, int n) : name(s), scores(n) {}
Student(const String & s, const ArrayDb & a) : name(s), scores(a) {}
Student(const char * str, const double * pd, int n) : name(str), scores(pd, n) {}
~Student() {}
double & operator[](int i);
const double & operator[](int i) const;
double Average() const;
// friends
friend ostream & operator<<(ostream & os, const Student & stu);
friend istream & operator>>(istream & is, Student & stu);
};
#endif
//
/////////////////////////////////////////
// strng1.h -- string class definition /
/////////////////////////////////////////
//
//
#include <iostream>
using namespace std;
#ifndef _STRNG1_H_
#define _STRNG1_H_
class String
{
private:
char * str; // pointer to string
int len; // length of string
public:
String(const char * s); // constructor
String(); // default constructor
String(const String & st);
//~String(); // destructor
int length() const { return len; } // -- Return the length of a stored string.
// overloaded operators
String & operator=(const String & st); // Assignment operator
String & operator=(const char * s); // Assignment operator #2
// friend functions
friend bool operator>(const String &st1, const String &st2);
friend bool operator<(const String &st, const String &st2);
friend bool operator==(const String &st, const String &st2);
friend ostream & operator<<(ostream & os, const String & st);
friend istream & operator>>(istream & is, String & st);
};
#endif
//
/////////////////////////////
// Listing 13.1 arraydb.h. /
// arraydb.h -- array class /
/////////////////////////////
//
//
#ifndef _ARRAYDB_H_
#define _ARRAYDB_H_
#include <iostream>
using namespace std;
class ArrayDb
{
private:
unsigned int size; // -- Number of array elements.
double * arr; // -- Address of first element.
public:
ArrayDb(); // -- Default constructor.
// -- Explicit keyword used to catch assignment errors (i.e. incorrect number of arguments).
explicit ArrayDb(unsigned int n, double val = 0.0); // -- Create an ArrayDb of n elements, set each to val.
ArrayDb(const double * pn, unsigned int n); // -- Create an ArrayDb of n elements, initialize to array pn.
ArrayDb(const ArrayDb & a); // -- Copy constructor.
virtual ~ArrayDb(); // -- Destructor.
// -- Returns array size.
unsigned int ArSize() const
{
return size;
}
double Average() const; // -- Return array average.
//
//////////////////////////
// Overloaded operators. /
//////////////////////////
//
virtual double & operator[](int i); // -- Array indexing; allow modifications.
virtual const double & operator[](int i) const; // -- Array indexing; read-only.
ArrayDb & operator=(const ArrayDb & a); // -- Assignment.
friend ostream & operator<<(ostream & os, const ArrayDb & a);
};
#endif
***************************************************************************************************
************************************** Source Files ***********************************************
***************************************************************************************************
//
//////////////////////////////////////////////////////
// Listing 13.4 studentc.cpp. /
// studentc.cpp -- Student class using containment /
//////////////////////////////////////////////////////
//
//
#include "studentc.h"
double Student::Average() const
{
return scores.Average(); // use ArrayDb::Average()
}
double & Student::operator[](int i)
{
return scores[i]; // use ArrayDb::operator[]()
}
const double & Student::operator[](int i) const
{
return scores[i];
}
// friends
// use String and ArrayDb versions
ostream & operator<<(ostream & os, const Student & stu)
{
os << "Scores for " << stu.name << ":\n";
os << stu.scores;
return os;
}
// use String version
istream & operator>>(istream & is, Student & stu)
{
is >> stu.name;
return is;
}
//
///////////////////////////////////////////
// Listing 13.2 arraydb.cpp. /
// arraydb.cpp -- ArrayDb class methods /
///////////////////////////////////////////
//
//
#include <iostream>
#include "arraydb.h"
using namespace std;
#include (bracket symbol) cstdlib (bracket symbol) // exit() prototype
//
//
/////////////////////////////////////////
// Default constructor -- no arguments. /
/////////////////////////////////////////
//
//
ArrayDb::ArrayDb()
{
arr = NULL; // -- Empty.
size = 0; // -- No value.
}
//
//
/////////////////////////////////////////////////////
// Constructs array of n elements, each set to val. /
/////////////////////////////////////////////////////
//
//
ArrayDb::ArrayDb(unsigned int n, double val)
{
arr = new double[n]; // -- Create new array.
size = n; // -- Number of elements in array.
// -- Loop through array.
for (int i = 0; i < size; i++)
arr[i] = val; // -- Place variable in array.
}
//
//
////////////////////////////////////////////////////
// Initialize ArrayDb object to a non-class array. /
////////////////////////////////////////////////////
//
//
ArrayDb::ArrayDb(const double *pn, unsigned int n)
{
arr = new double[n]; // -- Create new array.
size = n; // -- Number of elements in array.
// -- Loop through array.
for (int i = 0; i < size; i++)
arr[i] = pn[i]; // -- Assign value from one array to another.
}
//
//
/////////////////////////////////////////////////////////
// Initialize ArrayDb object to another ArrayDb object. /
/////////////////////////////////////////////////////////
//
//
ArrayDb::ArrayDb(const ArrayDb & a)
{
size = a.size; // -- Size of array dictated by ArrayDb object.
arr = new double[size]; // -- Create new array.
// -- Loop through array.
for (int i = 0; i < size; i++)
arr[i] = a.arr[i]; // -- Assign value from object-array to array.
}
//
//
///////////////////
// Deconstructor. /
///////////////////
//
//
ArrayDb::~ArrayDb()
{
delete [] arr; // -- Free-up memory created with new.
}
//
//
////////////////////////////
// Take average of grades. /
////////////////////////////
//
//
double ArrayDb::Average() const
{
double sum = 0; // -- Initialize sum-of-grades variable.
int i; // -- Counter variable.
int lim = ArSize(); // -- Get array size.
// -- Loop through array.
for (i = 0; i < lim; i++)
sum += arr[i]; // -- Summation of grades.
// -- If counter is true, then take average.
if (i > 0)
return sum / i;
// -- Else there were no grades to average.
else
{
cerr << "No entries in score array\n";
return 0;
}
}
//
//
////////////////////////////////////////////////////////////
// Let user access elements by index (assignment allowed). /
////////////////////////////////////////////////////////////
//
//
double & ArrayDb::operator[](int i)
{
// -- Check index before continuing.
if (i < 0 || i >= size)
{
cerr << "Error in array limits: "
<< i << " is a bad index\n";
exit(1);
}
return arr[i]; // -- Return with array-value.
}
//
//
///////////////////////////////////////////////////////////////
// Let user access elements by index (assignment disallowed). /
///////////////////////////////////////////////////////////////
//
//
const double & ArrayDb::operator[](int i) const
{
// --Check index before continuing.
if (i < 0 || i >= size)
{
cerr << "Error in array limits: "
<< i << " is a bad index\n";
exit(1);
}
return arr[i]; // -- Return with array-value (read-only).
}
//
//
/////////////////////////////
// Define class assignment. /
/////////////////////////////
//
//
ArrayDb & ArrayDb::operator=(const ArrayDb & a)
{
// -- Check to see if the object is assigned to itself.
if (this == &a)
return *this; // -- If it is, don't change anything.
delete [] arr; // -- Free-up memory.
size = a.size; // -- Get new size from object.
arr = new double[size]; // -- Create new array.
// -- Loop through array.
for (int i = 0; i < size; i++)
arr[i] = a.arr[i]; // -- Assign value from object-array to array.
return *this;
}
//
//
//////////////////////////////////////
// Quick output, 5 values to a line. /
//////////////////////////////////////
//
//
ostream & operator<<(ostream & os, const ArrayDb & a)
{
int i;
for (i = 0; i < a.size; i++)
{
os << a.arr[i] << " ";
if (i % 5 == 4)
os << "\n";
}
if (i % 5 != 0)
os << "\n";
return os;
}
//
///////////////////////////////////////////////////////////////////////////
// use_student.cpp : Defines the entry point for the console application. /
///////////////////////////////////////////////////////////////////////////
//
//
#include <iostream>
#include "stdafx.h"
#include "studentc.h"
using namespace std;
//
//
/////////////////////////
// Function prototypes. /
/////////////////////////
//
//
void set(Student & sa, int n);
//
//
///////////////////////////
// Variable declarations. /
///////////////////////////
//
//
const int pupils = 3;
const int quizzes = 5;
//
//
///////////////////////////
// Start of main program. /
///////////////////////////
//
//
int _tmain(int argc, _TCHAR* argv[])
{
Student ada[pupils] = {quizzes, quizzes, quizzes}; // -- Create student object arrays.
int i;
for (i = 0; i < pupils; i++)
set(ada[i], quizzes);
for (i = 0; i < pupils; i++)
{
cout << "\n" << ada[i];
cout << "average: " << ada[i].Average() << "\n";
}
return 0;
}
//
//
/////////////////////////////////////////
// Function to register pupil's scores. /
/////////////////////////////////////////
//
//
void set(Student & sa, int n)
{
cout << "Please enter the student’s name: ";
cin >> sa;
cout << "Please enter " << n << " quiz scores:\n";
for (int i = 0; i < n; i++)
cin >> sa[i];
while (cin.get() != '\n')
continue;
}
***************************************************************************************************
****************************** End of Source Files ************************************************
***************************************************************************************************
|
|
|
|