|
Thanks for the great example Dave, I'll spend some time with it. I did get the rand() working.
Thanks, Dave
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
My application uses a single window, but I'd like it use real time video from a capture card as the background, and have text displaying over it.
I'd like input text displayed in one area of the window, output text in another area etc..
My concept is to have additional windows with transparent backgrounds for displaying the text.
I have to admit I'm a rookie programmer, so hope someone can help or point me in the right direction.
regards
ribbs
|
|
|
|
|
I have a tree view that has some drag and drop features however i would like to cuase the tree to scroll when the user drags item to the bottom of the tree does how do i cuase the tree view to scroll ?
on a side not i want to be able to handle multiple popup menu clicks in 1 function within the tree view how would i determine what menu item was clicked? and is there a function that already exists that i can use?
|
|
|
|
|
1- I think the way to do this is to add a timer and manually scroll the tree view.( I might be wrong) but I don't know how to do it right now.
2- you can use the ON_COMMAND_RANGE() message to send multiple commands to a single function, the handler receives the ID as a parameter; but you need to have the IDs consecutive, which can be dangerous in the long run; it is preferable to have one handler for each menu entry and from each function, call one other function.
If you are using popup menu with TrackPopupMenu, you can have tre function return which menu item you clicked.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
i created the dialog class associated with my menu.
say, click on File, then , Move,, the dialog (COrigin) pops up
now,, in the dialog, when the user clicks on a button, IDC_BUTTON1
the function associated with this button is:
void COrigin::OnButton1()
{
//I have to get a pointer to change a variable in the View or Doc class
//which ever is easier.
}
Ehsan Behboudi
|
|
|
|
|
The easiest way to do it would be to put a function in your dialog class that takes a doc or view pointer, example:
void COrigin::SetDocument(CMyDocument *pDoc)
{
myDocPtr = pDoc;
}
And then wherever you need to use the document, you can use myDocPtr. Whoever creates and calls up the dialog would be responsible for setting the document pointer, it'd go something like this:
COrigin dlg;
dlg.StDocument(blah);
dlg.DoModal();
If you have an SDI doc, you could probably fidn a way of geting the document from the applicaiton class, but doing it tihs way makes it more flexible in case you ever go MDI.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
I'm working on a project and i need some sort of list object in memory, it just has to exist in memory, i'm not talking about a gui list or anything. The list should be able to hold anything i want... like.. every entry should have its own unique ID (an integer value), a name (a string value) and possibly others. But each new entry will have the same types of values as the others, if u know what i mean. Then i should be able to add entries and remove them quite easily by calling a function on it or something sort of like this:
list.AddEntry(<unique id>,<name>, etc...);
list.RemoveEntry(<unique id>);
I hope u know what i mean. Now my question is, how is this commonly done? Do people build their own structure or something? and write all the add and remove code themselves? Or is there maybe an existing object i can use (and i'm not talking MFC, just basic c++ with stdlib etc.). I've seen someone use a vector or something before but i'm not sure what thats about, and they used a strange way to declare the variable like..
int<vector> bla;
or something like that..can't quite remember.
But anyways i'm just looking for the right way to do it
Thank you.
Kuniva
--------------------------------------------
|
|
|
|
|
If the IDs are not sequental use a map, otherwise a list or vector will do.
vector<int> intvec;
John
|
|
|
|
|
Thanks! But do you happen to know where i can find more information about a "map" since i have no clue what that is..
Kuniva
--------------------------------------------
|
|
|
|
|
|
hi
I have a single document , MFC project, with a few dialog classes.
In one of the dialog member functions, i have to get access to a member variable of my View class.
How can I do that..
its basically a pointer to the view class
what is the code
Ehsan Behboudi
|
|
|
|
|
Pass the dialog a pointer to the view class before you call DoModal().
John
|
|
|
|
|
how u write a sample code please?
Ehsan Behboudi
|
|
|
|
|
Where do you create the dialog? From your view??
John
|
|
|
|
|
i created the dialog class associated with my menu.
say, click on File, then , Move,, the dialog (COrigin) pops up
now,, in the dialog, when the user clicks on a button, IDC_BUTTON1
the function associated with this button is:
void COrigin::OnButton1()
{
//I have to get a pointer to change a variable in the View or Doc class
//which ever is easier.
}
Ehsan Behboudi
|
|
|
|
|
If the data is needed in your view, you might want to keep the variable as a member of the view, and pass a pointer to the view to the dialog.
or send a message ( with SendMessage ) containing the variable and handle it in the view.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
So the dialog is created in the view or the doc?
I assume it is the view.
Add variable to your dialog
class CMyDialog : public CDialog
{
public:
CMyView* m_pMyView;
}
Then in our view
CMyView::OnMenuButtonPushed()
{
CMyDialog dlg;
dlg.m_pMyView = this;
dlg.DoModal();
}
John
|
|
|
|
|
Getting your data directly from the view in a single document application is bad design to some degree, because it breaks the SDI template. You can expect major reusability issues when you link your dialog directly to the view, since the view in turn is linked to the document.
If you can help it, try declaring member variables for the data in the dialog and fill those members with the actual data from the document just before you call domodal. After the dialog returns, read the changes from the member variables back to the document. This way you’ll get a dialog class, which does not ‘directly’ depend on a particular view or document class.
Concepts like this will not make your app work any different, but they will help maintenance and improve reusability.
Lorenz Prem
Microsoft Corporation
|
|
|
|
|
I'm having a hard time getting the rand function to work. I know that rand ( ) retruns a randow number, but I'm not sure how to do it? I posted some simple code below. What should be my return? Do I just pass the highest number of my range into the argument box of rand ( )? I'm looking through my books, but have found little to help me. How do I get rand( ) to work? Also, what's the difference between rand, srand and nrand. I know that srand starts a new seed sequence but am not sure what that means.
<br />
#include <stdlib.h><br />
#include <iostream.h><br />
<br />
int main()<br />
{<br />
int x = 150;<br />
int rand (x);<br />
return ;<br />
}<br />
Thanks, Dave
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
If you don't use srand(TIME(NULL)) to seed rand(), you'll get the same random numbers every time!
if the maximum should be 150 you can do the following:
int nRandomNumber = (rand() % 150) + 1;
your code will produce linker errors!
int rand() is a declaration. the rand function does not take parameters and your main function does not return a value!
hope this helps...
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Bob, I'm a bit confused on the rand function being a declaration. Does this mean that rand ( ) should only appear in a header file and not in the source file. How can you tell when a function is a declaration or if it belongs in the source file? Is it because of the "int" in front of rand( ) that makes it a declaration?
Thanks, Dave
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
DaveE9th wrote:
Does this mean that rand ( ) should only appear in a header file and not in the source file.
No it does not and most likely it will be in the source file.
John
|
|
|
|
|
A declaration looks like this: return type name(arg list);. It's predefined, that means that you only have to use it! Therefore it should only appear in a source file!
You should seperate 3 things:
1) declaration => Header File
2) Implementation => Source File
3) Call to a function => Source File (within other functions)
A Implementation looks like this:
return type name(arg list)
{
// source code
}
I assume you know how to call a function...
hope this helps
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
srand() seeds the pseudo random number generator. Many, if not most, developers just use the time function for this.
rand() returns a pseudo random number from 0 to RAND_MAX. To get a random number in an range, use the modulo operator with the max value plus one. In other words to obtain a random number from 0 through 5 do the following:
int x = rand() % 6;
Never heard of nrand().
|
|
|
|
|
Thanks, I'll try those out.
Dave
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|