|
PJ,
I had originally typed WM_KEYDOWN in my post, but then I thought that one would only want the change of focus to come after the key had been released, clearly ignoring that focus changes if you hold down the tab key.
Thanks for the correction!
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
You're in luck, Windows supports what you want to do and I've done something similar myself.
1. Create a placeholder static control in the dialog used for the form view, and make it the same size as the area where the child dialogs will be put.
2. In OnInitDialog() , get the RECT of the placeholder, then destroy the placeholder.
3. Next, create your child dialogs using the RECT you got in step 2 for the dialogs' initial size. VERY IMPORTANT: All child dialogs must have the WS_EX_CONTROLPARENT style. You can set this in the resource editor; you should also turn off the visible style, set them to all be child dialogs (not the default of popup), no caption, and no border.
4. After creating each dialog, use SetWindowPos() to position it in the right place in the tab order. For example, if the child dialogs should be after IDC_FOO in the tab order, do:
wndChildDlg.SetWindowPos ( GetDlgItem(IDC_FOO), 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
for each dialog.
After that, It Just Works because the default dialog proc sees the WS_EX_CONTROLPARENT style and does the keyboard handling for you.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer.
-- Michael P. Butler in the Lounge
|
|
|
|
|
I did the creation of the child dialogs a little differently, and I also had to set Control parent on the formview template.
Brilliant! Thanks mucho!
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
My C++ program needs to read some structured datasets, or compound datasets just like database tables, but without pre-defined data structure. The structure of a dataset can only be determined at run-time and varies from one dataset to another. I don't know how to define a "generic" data structure so that it can change with datasets dynamically. Can anyone give me a help? Thanks in advance.
Fiona
|
|
|
|
|
Hi,
Could you be a little more specific in your question? When you say "datasets just like database tables" are you actually reading the data from a database, from a flat file, or from some other source? Also, is your question how to read these datasets whose structures are unknown until run-time, or how to make a generic data structure to store them once they have been read?
I can try and help you if you answer these questions.
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Hi,
Thanks for your reply. My specific task is to write a data viewer interface to read and display data from files in a particular format. Datasets in a file can be a n-dimensional array of same type, or can be a compound table of different data type, that is what I said like a database table. When I access a data file, I have got some library functions to determine what type of a dataset is, if it's a compound table, the library functions also return how many columns in the table and what data type for each column. For example, if I know a compound table consisting of an "int" type and a "double" type, then I can define a structure like:
struct MyType
{
int a;
double b;
};
and then pass an array of this struct to the "readdata" function to receive the table data. However, as table structures vary with datasets, I cannot pre-define a struct like before. That's what I said I need some generic structure. Actually, the "readdata" library function returns a void pointer to the memory buffer that receives data from the file. The data strcuture on the memory buffer is same as the actual data structure in the table. That's why I want to define a strcut array to recieve data.
Hope this clarifies my problem and hope you can help me sovling this problem.
|
|
|
|
|
Hi,
I apologize for begin so remiss in getting back to you. I've been thinking a bit about your problem and it seems that, since the data formats are dynamic you won't be able to define structs, since you would have to do this at compile-time.
I think perhaps your best approach would be to use void pointers and casting. For instance, you could have a struct which would represent one column like this:
<br />
struct column<br />
{<br />
int dataType;
CPtrArray data;
}<br />
To represent a table, then, you would create an array of columns. If you wanted to use data from a column, you can create a function to detect the dataType, then cast the void pointer to the right data type for use.
On a different note, you could try creating template classes to handle the data. This would probably be a cleaner method than the void* method, but might require more coding.
I'm not sure if, in your implementation, either of these ideas will work. Let me know if neither of them works and I will try to think of something else.
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Hi,
Thank you very much for your help. My implementation extends the "column" struct you suggested to a struct holding the whole table instead of columns, eg. an enum array to record column types, and an array to store data size of columns. I am not confident to use void pointer since I read from some source that void pointer is unsafe in C++. So I defined a unsigned char buffer to receive the whole table contents, then retrieve field data from the buffer according to the field type.
Thanks again,
Fiona
|
|
|
|
|
Hi, I'm fairly new to Visual C++. Since recently learning it, I'm still a little unclear of what these parts or the program mean. I've created a list of important keywords and have given (to the best of my knowledge anyway) the meaning of each. If I've incorrectly got the meaning of any of the below wrong, could someone inform me on what to change it to.
The reason I'm doing this is because I know that I need to completely understand each meaning, otherwise learning C++ would be that extra bit harder! If anyone can help me, please do! Thanks, oh and apologies if this message has been asked before!
-All STATEMENTS end with a semi-colon
-DECLARATION is another type of statement which introduces variables to the compiler
-The ASSIGNMENT expression '=' is used to assign a value to a variable
-FUNCTIONS allow you to re-use duplicates of a declaration; meaning less coding
-STRUCTURES are groups of data which are contained within one declaration.
--e.g. :
My Friends Names
||
\/
School -> Joe, Carl, Emily
||
\/
Work -> Andy Philip, Indy
||
\/
Misc -> Ashley, Jake, Zoë
-CLASSES are similar to structures except you can have them public or private
--PUBLIC means the whole program can use the code
--PRIVATE means the code in only accessible within the class
drjake
|
|
|
|
|
Post a specific question.
Kuphryn
|
|
|
|
|
drjake wrote:
CLASSES are similar to structures except you can have them public or private
Wrong. structs members are public by default, classes are private by default
Buy a book, maybe C++ for dummies ? It sounds like you need to start with something that moves over the basics at a reasonably slow pace.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Christian Graus wrote:
drjake wrote:
CLASSES are similar to structures except you can have them public or private
Wrong. structs members are public by default, classes are private by default
"Wrong" is not the right answer. Yes, default it is, but:
drjake wrote:
CLASSES are similar to structures except you can have them public or private
which is true, when you use the correct access specifier such as "private:", or "public:"
Bikram Singh
|
|
|
|
|
bikram singh wrote:
"Wrong" is not the right answer.
Yes, it is. He said
bikram singh wrote:
CLASSES are similar to structures except you can have them public or private
That is wrong. It implies that struct members cannot be changed between public or private. Protected didn't even get a mention, but that's another story. As I pointed out, all that changes is what the default is, the meaning of default is the value you get if you don't specify one, so it was implicit in my answer that they could be changed.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
You would idd better buy a book, but here some answers by examples:
statements:
x = y + z;
Object.SomeFunction(int parameter1, CString parameter2);
CString str = "Some stupid text here.";
Definition:
int x;
double y;
CString str2;
Declaration:
x = 3;
y = 12.3;
str2 = "Hello World!";
(mind definition and declaration can come in 1 line: int x = 4;)
assignment: (see above assignments enough)
Function:
you can call a sequence of code again and again (more specific, a part of code that does something convenient)
int AddTwoInts(int x, int y){
int z = x + y;
return z;
}
Structures generally do not have functions (but they can have them) They mostly only contain data that is part of something bigger. (eg. Struct person could contain a CString name, int height, double weigth);
classes mostly do have functions.
you can consider classes like objects. Objects have data(properties) like integers, doubles and strings. And Objects can do something -> functions.
private, public: Acces level for other classes.
Note: mind ";" => STATEMENTS!
this is probably not entirely correct but gives you some idea to start with I think.
hope this helps.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I am having problems with using MSFlexGrid Control. The problem is that i am trying to input in the cells of the FlexGrid at run time by using a floating edit box which pops-up when the user double clicks a pariticular cell. The problem is that edit box is drawn in pixels while the cells of MSFlexGrid are in TWIPS. I couldn't found any conversion formula.
Please tell me how could i change the units of a dialog box (or a particular control) in TWIPS or suggest another way to solve the problem.
Thanks
Naveed
|
|
|
|
|
CMSHFlexGrid m_Table;
CDC *hDC;
hDC = GetDC();
long twips;
CRect aRect;
twips = m_Table.GetCellLeft();
aRect.left = MulDiv( twips, hDC->GetDeviceCaps( LOGPIXELSX ), 1440);
twips = m_Table.GetCellTop();
aRect.top = MulDiv( twips, hDC->GetDeviceCaps( LOGPIXELSY ), 1440);
twips = m_Table.GetCellWidth();
aRect.right = MulDiv( twips, hDC->GetDeviceCaps( LOGPIXELSX ), 1440)\
+ aRect.left;
twips = m_Table.GetCellHeight();
aRect.bottom = MulDiv( twips, hDC->GetDeviceCaps( LOGPIXELSY ), 1440)\
+ aRect.top;
this->ReleaseDC( hDC );
I hope that this works for you.
|
|
|
|
|
Sorry, but I forgot to mention that this code was handled after you click on a cell.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
Some general info:
- TWIPS = 1/1440 inch
- POINTS = 1/72 inch
- in normal WINDOWS text: 1 pixel = 12 twips
On my PC this conversion works quite well. To be exactly right you would want to know your screen size in inches(don't know if you can know this via code) and your screen resultion. (via ::GetSystemMetrics function)
Hope this helps a little.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I have a question.
I have some headers files in a directory which has been created inside the project directory. When I want to include the header file from a .cpp file the compiler says "no such file or directory"
My question is where to add (projects settings) a path to the headers??
Please help me
|
|
|
|
|
Project | Settings | C/C++ | Preprocessor | "Additional include directories"
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hello all,
Got a small problem that I was hoping I could get some help on. Using the CView class I need to get the current screen DPI. I know that I can use the GetDeviceCaps method in the CDC class to get the current DPI. The problem is that I want to retreive the values and store them somewhere in a variable BEFORE CView's OnDraw method. For example I tried this in CView's constuctor:
CTestView::CTestView()
{
CDC *Test;
Test = GetDC();
PixPerInchX=Test->GetDeviceCaps(LOGPIXELSX);
PixPerInchY=Test->GetDeviceCaps(LOGPIXELSY);
ReleaseDC(Test);
}
PixPerInchX, and PixPerInchY are defined elsewhere as an INT.
When I run this, it ASSERT fails. I think that my Test pointer is coming up NULL. Any ideas?
(P.S. I'm not a very good programmer yet, so if this is stupidly obvious I apologize.)
Thanks,
JD
|
|
|
|
|
Look at the assertion that is failing for an idea of what MFC was testing for.
When the CTestView constructor runs, it's not yet a window, it's just a C++ object, so any window-related functions that operate on the view window (like GetDC() ) will fail. CView::OnInitialUpdate() is a good place for initialization.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Wizard needs food, badly!
|
|
|
|
|
Okay, that worked. However when the code runs inside of OnInitalUpdate GetDeviceCaps returns garbage. (Well, the variable contains garbage when I look at it, anyways). When I run the same code inside the OnDraw it returns the expected value. (96) Any ideas on that one?
Thanks, JD
|
|
|
|
|
hi,
in my code i do myRS->AddNew() and after that i do myRS->MoveFirst().
when i do that i get exception... why is that?
|
|
|
|
|
Is the new record being added successfully? Have you checked the database for that? Sometimes you get an exception because you are doing something illegal but it will not appear right away.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|