|
Terry O`Nolley wrote:
use the DDX_GridControl function instead of the DDX_Control function (just manually change the ClassWizard entry).
This is what you need to do.
John
|
|
|
|
|
John M. Drescher wrote:
This is what you need to do.
I am trying to do that, but the control ID for the grid control doesn't appear in class wizard.
The dialog box that contains the grid control fires up when it is supposed to and I included the GridCtrl.h in the source file for the dialog class that contains the grid control.
But when I go to Class Wizard, the only controls it sees are the 2 default buttons.
The grid control appears in the class wizard's first screen when I select the CDIalog derived class that holds the GridCtrl, but it disappears when you click on the Member Variables tab.
I realize the documentation is probably more than enough for most people but I guess I am just dense
|
|
|
|
|
Add this to your class definition:
CGridCtrl m_Grid;
Add this after CDialog::DoDataExchange(pDX); in your DoDataExchange(CDataExchange* pDX) member function
DDX_GridControl(pDX, IDC_GRID, m_Grid);
John
|
|
|
|
|
Grinding along. Thanks for putting up with me.
Well, I added the following:
At the top of my dialog class header file, I added #include "GridCtrl.h"
In my dialog class header file at the top of the public: section I added CGridCtrl m_Grid;
I added DDX_GridControl(pDX, IDC_GRID, m_Grid); per your instructions
When I compiled, I got this:
c:\dev\visualstudio\vc98\include\wtypes.h(369) : error C2632: 'char' followed by 'char' is illegal
c:\dev\visualstudio\vc98\include\wtypes.h(369) : warning C4091: 'typedef ' : ignored on left of 'unsigned char' when no variable is declared
c:\dev\visualstudio\vc98\include\wtypes.h(375) : error C2628: 'DWORD' followed by 'unsigned' is illegal (did you forget a ';'?)
c:\dev\visualstudio\vc98\include\wtypes.h(375) : error C2628: 'DWORD' followed by 'long' is illegal (did you forget a ';'?)
c:\dev\visualstudio\vc98\include\wtypes.h(375) : warning C4091: 'typedef ' : ignored on left of 'unsigned long' when no variable is declared
Is this maybe a #if defined block that is being left open somewhere?
|
|
|
|
|
Are you compiling for UNICODE??
[EDIT]
I am really not sure what is causing the problem is in this case.
[/EDIT]
John
|
|
|
|
|
No unicode.
I'm about ready to shell out the $500 bucks for HalloGram's Ultimate Grid.
Thanks for walking through this with me.
If I ever get this to work, I am going to submit an article that walks a newbie to MFC through getting the thing to function.
|
|
|
|
|
Don't be discouraged. I am not sure what your problem is but it should not be too hard to fix. I have used the grid in at least 5 of my applications...
John
|
|
|
|
|
Why don't you try creating a simple dialog application and place a grid in it to see how to get it working?
John
|
|
|
|
|
Do you have UCHAR or ULONG defined in any of your files?? That looks like it is the problem..
This is line 369 of wtypes.h
typedef unsigned char UCHAR;
To me the error says that UCHAR is defined as char already...
[EDIT]
I tested this theory by putting a
#define UCHAR char
in my stdafx.h file and I got the following errors:
StdAfx.cpp
d:\pf\microsoft sdk\include\windef.h(47): error C2632: 'char' followed by 'char' is illegal
d:\pf\microsoft sdk\include\windef.h(47): warning C4091: 'typedef ': ignored on left of 'unsigned char' when no variable is declared
d:\pf\microsoft sdk\include\wtypes.h(379): error C2632: 'char' followed by 'char' is illegal
d:\pf\microsoft sdk\include\wtypes.h(379): warning C4091: 'typedef ': ignored on left of 'unsigned char' when no variable is declared
d:\pf\microsoft sdk\include\sqltypes.h(109): error C2632: 'char' followed by 'char' is illegal
d:\pf\microsoft sdk\include\sqltypes.h(109): warning C4091: 'typedef ': ignored on left of 'unsigned char' when no variable is declared
[/EDIT]
John
|
|
|
|
|
Exactly!
I double clicked on the compile error and found that line in wintypes.h.
I commented it and the other typedef error out .
When I got a good compile, I guessed that it must have been defined in one of the GridCtrl files - or else there would have been an error.
So after I commented it out and built the executable, I uncommented it again and as of 2 minutes ago it was working.
Now I'm going to dig through GridCtrl files to see how it was defined. Hopefully it was defined the same way as in wintypes.h
I was just checking back in to thank you again and tell you what the problem was
|
|
|
|
|
Okay - I found the culprit. I was assuming the redefinition was in the GridCtrl files, but it is in the Victor Image Library files I am using. God help me if the Victor library definition is different that the Windows typedefs........
|
|
|
|
|
Oh man. Now that I got it to compile I am trying to use it.
In my OnInitDialog handler, I set the columns to 10 and rows to 10 and set the first row as a fixed row. no prob - looks great.
Also in OnInitDialog I called m_Grid.SetItemText(1, 1, "ID"); and it returned FALSE - failure.
Is there an entire bunch of initialization hoops I need to jump through?
I was hoping I wouldn't need to start carving out pieces of the example project. The docs looked easy enough for me to jump right in but it just isn't happening for me..........
|
|
|
|
|
Have you tried tracing the calls using the debugger?
cheers,
Chris Maunder
|
|
|
|
|
Have you declared IDC_GRID in your resource.h file?
cheers,
Chris Maunder
|
|
|
|
|
Hey there!
Thanks for making this tool available to us all. I was looking for a grid and couldn't find anything except for Active-X controls. Yours seemed to be just what I was looking for.
Chris Maunder wrote:
Have you declared IDC_GRID in your resource.h file?
It is declared and appears properly when I click the button to display the dialog box that contains it. The calls to m_Grid.SetColumnCount();, m_Grid.SetColumnCount(); & m_Grid.SetFixedRowCount(); work fine and the grid displays with the proper number of rows, columns and fixed rows.
But when I go the next step and call m_Grid.SetItemText(1, 1, "ID"); it returns FALSE.
Note that all of the above calls are in my OnInitDialog handler.
=============== EDIT =====================
Nevermind I discovered the problem. I was trying to set the text of the first (fixed) row but forgot to reference it as the zeroeth row. EXCELLENT work!!!!!!!!!!!!!!!!
|
|
|
|
|
In your resource file:
#define IDC_GRID 1004 In your header:
#include "GridCtrl_src/GridCtrl.h"
class CGridCtrlDemoDlg : public CDialog
{
public:
...
CGridCtrl m_Grid;
In your implementation file:
...
void CGridCtrlDemoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
...
DDX_Control(pDX, IDC_GRID, m_Grid);
}
...
BOOL CGridCtrlDemoDlg::OnInitDialog()
{
m_Grid.[SetSomeProperties...];
cheers,
Chris Maunder
|
|
|
|
|
Hi,
I have a doubt. How can I do to change the menu prompt at runtime ?
thanks.
|
|
|
|
|
menu prompt ?
the menu item text or the text that is displayed in the status bar when moving the mouse over a menu item ?
the first one is simple, use CMenu::ModifyMenu
the other things, I don't know .
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Hi,
Actually, I'm talking about the text that is displayed in the status bar when moving the mouse over the menu...
Can you help me ?
|
|
|
|
|
Often that text is retreived from your accelerator table or string table (recources!).
the only thing you can do (as far as my knowledge go's) is harcode the tooltips...
good luck, I think you need it...
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Dear Friends
As it is my first time to get a grip to commport, I've lots of problem with it, I used file operation method but it doesn't work properly, and notify by error 6 & 5.
I'd be appreciated if you could take a look at my code as bellow as advise me in this case
Regards
BOOL CMainFrame::InitSerialPort()
{
DCB dcb;
BOOL fSuccess;
char *pcCommPort = "COM1";
m_hComPort = CreateFile( pcCommPort,
GENERIC_READ | GENERIC_WRITE,
0, // comm devices must be opened w/exclusive-access
NULL, // no security attributes
OPEN_EXISTING, // comm devices must use OPEN_EXISTING
0, // not overlapped I/O
NULL // hTemplate must be NULL for comm devices
);
if(m_hComPort == INVALID_HANDLE_VALUE)
{
// Handle the error.
CString str;
str.Format("CreateFile failed with error %d.\n", GetLastError());
AfxMessageBox(str);
return FALSE;
}
fSuccess = GetCommState(m_hComPort, &dcb);
if (!fSuccess)
{
// Handle the error.
AfxMessageBox("GetCommState failed with error %d.\n", GetLastError());
return FALSE;
}
dcb.BaudRate = CBR_9600; // set the baud rate
dcb.ByteSize = 8; // data size, xmit, and rcv
dcb.Parity = NOPARITY; // no parity bit
dcb.StopBits = ONESTOPBIT; // one stop bit
fSuccess = SetCommState(m_hComPort, &dcb);
if(!fSuccess) //////////// this line hs been repeated ////////
{
// Handle the error.
AfxMessageBox("SetCommState failed with error %d.\n", GetLastError());
return FALSE;
}
return TRUE;
}
//**************************************************************************************************
void CMainFrame::OnCommClose()
{
m_ComPortOpened = FALSE;
m_isRunning = FALSE;
|
|
|
|
|
soobot wrote:
AfxMessageBox("SetCommState failed with error %d.\n", GetLastError());
AfxMessageBox() does not do variable substitution.
|
|
|
|
|
replace all of MessageBox's with
CString str;
str.Format("CreateFile failed with error %d.\n", GetLastError());
AfxMessageBox(str);
Then repeat your problem in board message.
If u wanna give a fast conclusion your message should be in first page of the forum.
|
|
|
|
|
Hi,
I have scanned in graphs which are now available in bitmap format and I wanna programmatically convert its curves (i.e. significant points) to coordinates expressed in numbers.
Please give me advice.
Bunburry
|
|
|
|
|
Hello,
I want to change FONT from one type to another type. Courier to Arial for example. Which function can help me to do that?
Thanks a lot.
|
|
|
|