|
AnTri wrote: Is the a better way to restore my CWnd* as the following:
Yes, but if you are only talking about a few edit controls, why not just store the CEdit object itself?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Do you mean a pointer to CEdit - Object? (the CEdit Object itself is located in my CFormView class). I thought CEdit is dervied from CWnd and thats why I originally stored the CWnd* pointer...
What do you think about my previous question?
Ok, but when nothing happens with my CFormView (Controls) why is my (stored) pointer invalid. I thought the CWnd* is valid as long as the window exits.
|
|
|
|
|
The problem you are having is that GetDlgItem actually returns a CTempWnd* pointer.
MFC keeps a map of all the windows that are created. It maps CWnd objects to HWND handles making it very fast for MFC to find a CWnd given an HWND. When you have a window that is not created via CWnd::Create (your dialog controls in this instance), those windows are not include in the map. If GetDlgItem finds the window you want in the map it will return that CWnd* pointer, if not it will create a CTempWnd* pointer that you can use as a CWnd, but it is not added to the map. When that CTempWnd* pointer goes out of scope the CWnd object (as opposed to the HWND handle it wraps and the window it points to) is destroyed. If you save that pointer for later use it will just point to garbage.
That is why the docs for GetDlgItem state:
The returned pointer may be temporary and should not be stored for later use.
|
|
|
|
|
PJ Arends wrote: When you have a window that is not created via CWnd::Create (your dialog controls in this instance), those windows are not include in the map.
Just an FYI, that is not entirely true... I am fairly certain that if you use CWnd::SubclassWindow(...) or CWnd::Attach(...) to associate a CWnd -based object with an HWND and then call CWnd::GetDlgItem(...) for that particular HWND 's control ID, you will get a pointer to that particular CWnd object, and not a temporary CTempWnd pointer.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Does anyone have a basic reference for working with a DLL in a VC++ program? For example, suppose I have Sample.DLL which contains function Setup(int, int). I presume I have to do something to link the DLL to my program? Include? Do I just use Setup(int, int) in my program? Do I have to declare it in my program? Qualify it? (What if another DLL also contains Sample(int, int)?)
I'm looking for an article like, "Getting Started With A DLL." Any suggestions? Thanks.
|
|
|
|
|
Look here[^], you'll probably find what you are looking for.
|
|
|
|
|
Thanks. Many of those articles are perfect for someone beginning to work with DLL's.
|
|
|
|
|
|
With Visio 2003 Pro there is an option to design (under) File -> New -> Windows XP User Interface option.
Is it possible to import this 'dialog' into a Visual Studio 2005 MFC C++ application. This would allow someone to design the GUI away from the target project; i.e. GUI design in Viso and implementation in Visual Studio.
Sorry if this is the wrong forum for this message.
Cheers,
Andy.
|
|
|
|
|
Does Visio export a format that VS can understand?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Can u suggest me Whitebox testing tools for vc++ application
For online audio/video communications
Freeware if any..
or any Links..
Thanks & Regrads
-- modified at 6:44 Friday 29th September, 2006
|
|
|
|
|
there are lots n lots of tools available now for white box and black box testing .....i m sending u one link may be it will help u
Shilpi
http://www.aptest.com/resources.html
|
|
|
|
|
Nice, but no freebies
|
|
|
|
|
can any of u refer some link for free tools
if not avaliable, which is the best amoung the commericial tools ?
Pls advice me
Thanks & Regrads
|
|
|
|
|
what exactly u want to test ....there are many black box testing tools in my knowlegde ...but white box ....hey i think u r confused in white box and black box testing ....bcoz according to me there is no white box automation tools for testing ...bcoz in white box testing tools we have to check code ...for black box ....u may use winrunner ....it is best solution for ....GUI application
i think it will help u
|
|
|
|
|
Hi,
We are developing a tool that output data to an excel sheet. In that, We need to color some rows in different colors through Program itself. We are using MFC coding. That is using the CDatabase Class. That is, somewhat like this.
sSql = "CREATE TABLE 90_Degree (NET_NAME TEXT,X1 int,Y1 int, X2 int,Y2 int, LAYER TEXT)";
database.ExecuteSQL(sSql);
We didnt know how to accomplish this task. So please help us in this.
With Regards,
Sangeetha.
|
|
|
|
|
This code has got absolutely nothing to do with coloroing the cells in Excel. You have supplied a SQL string that will create a table. Now,
1. Have you connected to excel first? (the "Halo from visual c++" message box)
2. For coloring the cells, simple VBA will do.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Yeah,
The coding is as follows:
CDatabase database;
CString sDriver = "MICROSOFT EXCEL DRIVER (*.XLS)";
CString sExcelFile = FileName;
CString sSql;
CString str1;
TRY
{
// Build the creation string for access without DSN
sSql.Format("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=\"%s\";DBQ=%s", sDriver,sExcelFile,sExcelFile);
// Create the database (i.e. Excel sheet)
if( database.OpenEx(sSql,CDatabase::noOdbcDialog) )
{
// Create table structure
int j = database.CanUpdate();
CAngle_CheckSet1* recset;
recset = new CAngle_CheckSet1(&database);
recset->Open(NULL,NULL,NULL,"'TABLE','SYSTEM TABLE'",CRecordset::snapshot);
CString TableName, sSql;
TableName = "\0";
if(!recset -> IsEOF())
{
recset->MoveFirst();
while(!recset->IsEOF())
{
TableName = "[" + recset->m_strTableName + "]";
recset->MoveNext();
}
}
recset->Close();
if(TableName == "[90_Degree]")
{
sSql = "DROP TABLE 90_Degree";
database.ExecuteSQL(sSql);
}
sSql = "CREATE TABLE 90_Degree (NET_NAME TEXT,X1 float,Y1 float, X2 float,Y2 float, LAYER TEXT)";
database.ExecuteSQL(sSql);
Here we can create table and send the data and had taken the output in excel also. But how to write the sql statement for coloring any of the rows.
ArraySize = m_NinetyArray.GetSize();
for(int i = 0; i < ArraySize; i++)
{
ErrorClass = (CError*) m_NinetyArray.GetAt(i);
// Insert data
CString Sql("INSERT INTO 90_Degree (NET_NAME, X1, Y1, X2, Y2, LAYER) VALUES (");
Sql = Sql + "'" + ErrorClass -> NetName + "'," + "%f,%f,%f,%f";
sSql.Format(Sql, ErrorClass -> X1 , ErrorClass -> Y1, ErrorClass -> X2, ErrorClass -> Y2);
Sql = sSql + "," + "'" + ErrorClass -> Layer + "'" + ")";
sSql = Sql;
database.ExecuteSQL(sSql);
}
sSql = "pset border 1";
database.ExecuteSQL(sSql);
sSql = "SELECT * FROM 90_Degree";
database.ExecuteSQL(sSql);
}
// Close database
if(database.IsOpen())
database.Close();
}
CATCH_ALL(e)
{
TRACE1("Driver not installed: %s",sDriver);
}
END_CATCH_ALL;
With Regards,
Sangeetha.
|
|
|
|
|
I humbly suggest you not to try coloring the cells in Excel using SQL. You may use VBA and get it done in a consideably lesser time. I have to admit that I do not know how to color cells in Excel using SQL though.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Hi Brahmma,
Thank you a lot for ur sugesstion. Can you suggest me some ideas about VBA? I am new to that.
With Regards,
Sangeetha.
|
|
|
|
|
Press (Alt + F11) from within Microsoft Excel will invoke the VBA editor. Add a module and code in it. Run your module to get the results. See my post below for sample code.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
|
Aljechin wrote: Thats funny
what?
nave
|
|
|
|
|
He wrote
I humbly suggest you not to try coloring the cells in Excel using SQL.
|
|
|
|
|
It would be simple. If you know the range, then you can operate on them. May be for example, if you need to change the font face in a given range say d5:e6, then the following code will do it (VBA, not sql)
Range("D5:E6").Cells.Font.Name = "verdana"
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|