|
Hey,
my goal is to show different dialog within a CTabCtrl depend on the selected tab item.
How can I display a dialog (Resource with DialogClass) in my TabCtrl. I tried the following, but it didn't work as expected:
header-file:
CMyDialog myDialog; //DialogClass
cpp-file:
<br />
m_tab.InsertItem(0, _T("Test1"));<br />
m_tab.InsertItem(1, _T("Test2"));<br />
<br />
CRect reTabCtrl, reListCtrl;<br />
<br />
m_tab.GetClientRect(&reTabCtrl);<br />
<br />
m_myDialog.Create(IDD_DIA_STANDARD, m_tab.GetWindow(0));<br />
<br />
m_myDialog.SetWindowPos(NULL,reTabCtrl.left,reTabCtrl.top,100,200,SWP_NOZORDER);<br />
<br />
myDialog.ShowWindow(SW_SHOW);<br />
<br />
|
|
|
|
|
Hi
I need to use 'RegQueryValueEx(...)' to retrieve a subkey's value.
<br />
CString strReturnWaarde("");<br />
long lResult=0L;<br />
DWORD dwLength=0L, dwType=0L;<br />
TCHAR keyValue[256];<br />
<br />
HKEY SrcKey;<br />
<br />
if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\COMPANY\\PRODUCT\\" + strKey, 0, KEY_READ, &SrcKey) == ERROR_SUCCESS ) <br />
{<br />
dwLength = 256*sizeof(TCHAR);<br />
lResult = RegQueryValueEx(SrcKey,strKeyName, NULL, &dwType, (BYTE*)keyValue, &dwLength );<br />
<br />
if ( lResult == ERROR_SUCCESS )<br />
{<br />
strReturnWaarde = CString(keyValue);<br />
} <br />
RegCloseKey(SrcKey);<br />
}<br />
::AfxMessageBox(strReturnWaarde);<br />
This code works when getting Text but not when trying to get numbers (DWORD).
What is wrong with it? :x
I replaced the 'strReturnWaarde' as ' int iReturnWaarde' and without the conversation to CString ofcourse.
Greetings
Jens
|
|
|
|
|
Hi,
The problem is in typcasting. It is right to cast the type into a pointer to byte (LPBYTE) but then you have to provide the adress of your DWORD variable too. Also keyValue must be of type DWORD.
Like:
<br />
DWORD dwType,dwLength,keyValue;<br />
...<br />
RegResult=::RegQueryValueEx(SrcKey,strKeyName,NULL,&dwType,(LPBYTE)&(keyValue),&dwLength);<br />
You may not use a TCHAR buffer array for this purpose. I couldn't find a way to cast this in a DWORD.;)
Regards
G. Steudtel
|
|
|
|
|
I have a dilemna. I have not used c++ in years in been thrown in to a project, that should be fairly simple, if I could remember anything about c++. I have a log file that I currently parse looking only for a specific set of data. The program parses the line that I need which is similiar to this:
Test Data A:1234\1234\12345678.dat File error: "Then the Error Message" to A:1234\1234\12345678.dat.$$$.WeekDay Month Day Time Year
I parse out the file looking for Test Data, displaying the entire line to write to the file in the directory.(a Then I need to compare the Error Message with the current possible error messages, if a match is found, write a note in the file stating what the error message means. I am having extreme difficulty getting the program to compare the error message to the possible error message and displaying another.
Copy of Code:
CFile file;
CFile outputfile;
CFileException exception;
int holder = (80);
if (!file.Open(fileNameStr, CFile::modeRead, &exception))
{
return false;
}
int count = 0;
char buffer;
CString TempBuffer;
CParser parser;
parser.Add((int)TOKEN_DATA_FILE, "Test Data ");
parser.Add((int)TOKEN_SECOND, "File Copy Failed on Data File ");
// parser.Add((int)TOKEN_DATA_M, "A: ");
parser.Add((int)TOKEN_MESS_1, "failed decryption ");
parser.Add((int)TOKEN_MESS_2, "Failed Decryption but Decompressed ");
parser.Add((int)TOKEN_MESS_3, "Failed Decompression ");
parser.Add((int)TOKEN_MESS_4, "Failed Decompression but Decrypted ");
parser.Reset();
while (file.Read(&buffer, 1) == 1)
{
T_TokenID currentToken = (T_TokenID)parser.CheckForToken(buffer);
switch ( currentToken )
{
case NO_TOKEN:
break;
case TOKEN_DATA_FILE:
{
CString objectStr("Data File M: ");
CString objectFDD("Failed Decryption & Decompression Message");
CString objectFDBD("Failed Decryption but Decompressed Message");
CString objectFDD2("Failed Decompression & Decryption Message");
CString objectFDBD2("Failed Decompression but Decrypted Message");
while (file.Read(&buffer, 1) == 1 && buffer != '\n')
{
objectStr += buffer;
}
if(objectStr.GetLength() > 95) {
m_lst_itemsInFile.AddString(objectStr);
}
/*
}
break;
case TOKEN_SECOND:
{
CString objectStr("File Copy Failed on Data File ");
while (file.Read(&buffer, 1) == 1 && buffer != '\n')
{
objectStr += buffer;
}
m_lst_itemsInFile.AddString(objectStr);
}
break;
/* case TOKEN_DATA_M:
{
CString objectStr("M:");
while (file.Read(&buffer, 1) == 1 && buffer != '\n')
{
objectStr += buffer;
file.Write(&buffer, 1);
}
m_lst_itemsInFile.AddString(objectStr);
}
break;*/
default:
{
ASSERT(false); // CheckForToken(buffer) should always return a valid T_TokenType
return false;
}
} // switch ( CheckForToken(buffer) )
}
file.Close();
return true;
}
Any help would be greatly appreciated.
|
|
|
|
|
Nevermind - got it figured out!
|
|
|
|
|
Hi!
I have made a ActiveX control in Visual C++.
This control should get files from a http server.
My ActiveX control is integrate in a Internet explorer window.
I want to use same Internet session in my control as the internet explorer window.
This because I use a securitybox to connect the https server in the explorer window.
I must have a logged on session in my control
//Thanks
|
|
|
|
|
Like some of the professional software , i plan to create an Uninstall Shortcut in the program files dir of my project. I am using InstallShield to create the shortcuts , but I dont know the shortcut information for the Uinstaller .
By default I have an Uninst.isu which is being used by some Exe i am not aware of .
My idea of creating an Uinstall shortcut would be to create a Shortcut for the "unknown" exe that accepts my Uninst.isu as a parameter !
is this methodology right ? Does anyone know the details of the Unknown exe ?
|
|
|
|
|
I am trying to change the compiler that VC++ .NET uses so I can connect to a database, but I can't find where the compiler is set. Could someone tell me how to change the compiler?
Thanks,
Joel L.
|
|
|
|
|
Is there a known bug with CString's find. I read a file into a CString and then used CString::find to locate some escape characters (MyText.Find("\n", start_loc) ). I tried the version without the starting location and it seems to work fine. However, the version with the starting loction returns a negative one. Is there a problem with the member function or am I just using it wrong??
|
|
|
|
|
Be careful of how you use the second parameter, the starting location. MSDN defines this as
nStart
The index of the character in the string to begin the search with, or 0 to start from the beginning. The character at nStart is excluded from the search if nStart is not equal to 0.
This implies that for a string value of :
<br />
CString strValue("0123456");<br />
int nPos = strValue.Find('3',3);<br />
..This will fail to find the '3', as the starting location is excluded from the search (apart from location zero.
I Dream of Absolute Zero
|
|
|
|
|
LINK : fatal error LNK1181: cannot open input file "fltk.lib"
I alredi included this file in the "include file " but still got this error
help me thx a lot
|
|
|
|
|
This linker error means that the linker is unable to open the designated file. The most common cause is that it cannot find the file.
You don't use #include with library files. If you need to link against a library, you add this library to the 'Additional dependecies' option of your project settings (Found in Project Settings->Linker). Then make sure that the library exists in one of the paths specified for the Visual Studio environment. If it doesn't, you need to copy it to any one directory specified there or add a new directory to the list.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi there!
This is my first time here, so please be kind if I do something wrong
I've got a tree ctrl with a customized background, and nearly everything works fine.
let me show you a pic of what i intend to do:
http://www.msuling.de/pics/whatiwant.gif[^]
I have nearly everything done, let me show you what I've got:
http://www.msuling.de/pics/whatigot_1.gif[^]
or
http://www.msuling.de/pics/whatigot_2.gif[^]
I have no clue how to make the lines and the boxes visible WITH a colored background.
If anyone outthere has an idea, I would be very pleased !
Oh, right, this is the code I use in OnPaint() my MultiColorTree-Class:
void CMultiColorTree::OnPaint()
{
CPaintDC dc(this);
CDC memDC;
memDC.CreateCompatibleDC( &dc );
CRect rcClip, rcClient;
dc.GetClipBox( &rcClip );
GetClientRect(&rcClient);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap( &dc, rcClient.Width(), rcClient.Height() );
memDC.SelectObject( &bitmap );
CRgn rgn;
rgn.CreateRectRgnIndirect( &rcClip );
memDC.SelectClipRgn(&rgn);
rgn.DeleteObject();
CWnd::DefWindowProc( WM_PAINT, (WPARAM)memDC.m_hDC, 0 );
HTREEITEM hItem = GetFirstVisibleItem();
int n = GetVisibleCount()+1;
while( hItem && n--)
{
CRect rect;
UINT selflag = TVIS_DROPHILITED | TVIS_SELECTED;
Color_Font cf;
if ( m_mapColorFont.Lookup( hItem, cf ))
{
{
CFont *pFontDC;
CFont fontDC;
LOGFONT logfont;
if( cf.logfont.lfFaceName[0] != '\0' )
{
logfont = cf.logfont;
}
else
{
CFont *pFont = GetFont();
pFont->GetLogFont( &logfont );
}
if( GetItemBold( hItem ) )
logfont.lfWeight = 700;
fontDC.CreateFontIndirect( &logfont );
pFontDC = memDC.SelectObject( &fontDC );
if( cf.color != (COLORREF)-1 )
memDC.SetTextColor( RGB(0,0,0) );
CString sItem = GetItemText( hItem );
GetItemRect( hItem, &rect, TRUE );
CRect tmpRect;
tmpRect.SetRect(rect.left,rect.top,rect.right,rect.bottom);
CBrush brush;
brush.CreateSolidBrush(cf.color);
memDC.FillRect(&tmpRect,&brush);
memDC.SetBkColor(cf.color);
memDC.TextOut( rect.left+2, rect.top+1, sItem );
memDC.SelectObject( pFontDC );
}
}
hItem = GetNextVisibleItem( hItem );
}
dc.BitBlt( rcClip.left, rcClip.top, rcClip.Width(), rcClip.Height(), &memDC,
rcClip.left, rcClip.top, SRCCOPY );
}
Thank you very much!
greetz
Tiberius
Is there a way to include pictures here?
----------------------------------------------------------
I once had a nightmare in binary --- I think there was a 2
|
|
|
|
|
Hi everyone,
The problem I've got is that I need to open a database (*.mdb, the filename is choosen by the user) and then write rows (recordset?) of data to different tables within the database (the names of the tables will never change, but the tables will not contain any data at the start of the run apart from the field names).
However there are some constraints:
1) I cant use anything to do with JET
2) I can include <afxdb.h> and <afxdao.h> as these cause compilation errors with the main library the software is built on. (the error is to do with GetTickCount, which is MFC even though its not used in the program and no methods exist in our code called GetTickCount!)
not sure if I've made this clear enough.... but if anyone has any suggestions and can provide links to websites which contain non-mfc database code samples.
many thanks
Andy McSherry
|
|
|
|
|
Hi,
Your post does not state clearly what the problem is. However, if you want to use non-mfc based database library, you can try using ADO.
Try:
http://www.developerfusion.com/show/4033/1/[^]
Hope, it helps.
Pankaj
Without struggle, there is no progress
|
|
|
|
|
cheers Pankaj
it looks like the link you gave me has what I need to do! (I did look at ADO before but all the examples talked about JET, which meant I didnt delve too far into it)
many thanks,
Andy
|
|
|
|
|
mcsherry wrote:
I did look at ADO before but all the examples talked about JET, which meant I didnt delve too far into it)
The Microsoft Access Databases uses the JET engine, so you cannot avoid this. You will have to interact with the JET engine to communicate with the database no matter what method you use. Maybe your boss was taking about not using a specific technology (MFC's DAO classes, for example)?
I Dream of Absolute Zero
|
|
|
|
|
2) should read
2)I can't #include <afxdb.h> and <afxdao.h> as these cause compilation errors with the main library the software is built on. (the error is to do with GetTickCount, which is MFC even though its not used in the program and no methods exist in our code called GetTickCount!)
|
|
|
|
|
Sorry, replied above before reading this ammendment.
Those include files are MFC's database classes CDAOXXXX. ADO is definitely the way to go. You can find one or two very good ADO wrapper classes right here in CP to use in your project.
I Dream of Absolute Zero
|
|
|
|
|
About GetTickCount errors, maybe it has to do with the macro GetCurrentTime which is defined as GetTickCount for backward compatibility.
If that's the case, simply undefing the macro will do the job.
|
|
|
|
|
How to disable all ASSERTs in Debug mode?I am using a memory leak tool called as entrek, and the recurring ASSERTs make it difficult to execute the program. (I am getting timecore.cpp asserts every 1 sec as there is one thread which sets the timer every 1 sec, i haven't checked the details as to y these asserts r coming)
This is very urgent. Any help appreciated.
|
|
|
|
|
If you are using some memory leak prog thats great, but if you are getting asserts then your prog is not even ready to pass the first test of "good program" then comes the memory leak test.
I would suggest to find and rectify the problem that is causing the assert.
I Touched Osama Bin Ladens Bushy Beard
|
|
|
|
|
Thnks ,
I have no idea and time to look into the ASSERT problem. Its in timecore.cpp.
I need to send this urgently.
|
|
|
|
|
write in your code:
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
The message will be written to the debugger's output window.
|
|
|
|
|
Hello,
in my VC++ application, I use ODBC dbf files driver to access a file.dbf.
In my code, I open the data the database connection (it works normaly).
Then I do my request : "SELECT Field1,Field2 FROM tab WHERE (Field0 = value)".
Here, I recieve an ODBC error message "Impossible de trouver le fichier memo xBase Demande", in english it can be traduced by "impossible to find the requested xBase memo file" ....
1) what does ODBC want to say with this message ?
2) what is the cause of this message
What is strange : I just open the file dbf with Excel (no modification in file, no save of file, just open to view the content), I restart my VC++ application and the Select returns me some rows ... just as the fact to have the file opened makes it work ...
I tried several times and without Excel, I have the msg, with excell it works ...
Any idea appreciated
DD
|
|
|
|
|