|
Thanks I will look into it. Does this work with VC++ 6.0 by any chance?
Every nation ridicules other nations, and all are right. - Schopenhauer
|
|
|
|
|
JWood wrote:
Does this work with VC++ 6.0 by any chance?
I have not tried it - my project was working with VC++ 7.0 anyway.
But I remember to have read smething about 'VC++ 7 only'. I am not sure about that, though.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Hi there...
Guess this is just my week for inane behavior.
I have implemented a tab control in a child window. It behaves as intended, I can insert tabs, select tabs, get data from them, change focus, etc, etc.
However, the string for the tab refuses to appear on the display ?? I've tried a number of different methods to put the string into the TC_ITEM struct (std::string, C string buffer, strcpy, string literal, sprintf). It all compiles and when traced with a debugger the string appears to have been copied to the TC_ITEM appropriately and when I get the tab after a user has selected it, the string is populated as I had set it. The control is just refusing to display it at run time.
a code snippet of my population method follows.
Would someone be so kind as to point out what I am doing wrong?
Thanks
Dave
--- cut & paste -----------------------------
// got a new element, populate a tab
char nodename[50];
ZeroMemory( nodename, sizeof(char) * 50 );
sprintf( nodename, "%s", r->name.c_str() );
TC_ITEM tab;
tab.dwStateMask = TCIF_TEXT | TCIF_PARAM | TCIF_IMAGE;
tab.dwState = 0;
tab.iImage = -1;
tab.pszText = (LPSTR)nodename;
tab.lParam = (LPARAM)r;
tab.cchTextMax = 25;
index = list.size();
// insert the tab into the display
if( TabCtrl_InsertItem( hTab, index, &tab ) > -1 )
{
// focus on tab
TabCtrl_SetCurSel( hTab, index );
TabCtrl_SetCurFocus( hTab, index );
// store the tab
list.push_back( tab );
}
else
{
MessageBox( NULL, "An unexpected error has occured while inserting tab!", "Tab Cntrl Error", MB_ICONERROR|MB_OK );
LOG->Write( "recview.h", sal::Log::error, "In UpdateTabs(): failed to insert new tab" );
}
|
|
|
|
|
Perhaps tab 's lpReserved1 and lpReserved2 members contain random values? (They must be zero.) Try ZeroMemory() 'ing tab before using it.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I see four problems there.
1. You're not zero-initializing the TCITEM struct. Always do this.
TCITEM tab = {0}; 2. The TCIF_* flags go in the mask member, not dwStateMask .
3. The cchTextMax member is set to 25, not the actual length of the string. cchTextMax is actually not used when you're setting the text, since the control assumes the string is zero-terminated, but the fact that you're setting it wrong makes me think you'll have problems elsewhere when cchTextMax is used.
4. You're storing a TCITEM struct in a list, but the TCITEM contains a pointer to a char array on the stack. As soon as that array goes out of scope, the pointer becomes invalid.
--Mike--
LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Thanks for the replies!
As it turned out, you were on the money with the mask member. This is my first forary into tab controls, and obviously misread the MSDN docs.
Michael Dunn wrote:
4. You're storing a TCITEM struct in a list, but the TCITEM contains a pointer to a char array on the stack. As soon as that array goes out of scope, the pointer becomes invalid.
Sorry for the confusion, I should have explained the snippet more clearly to avoid leading people down the wrong track. "list" is actually a ref to a vector passed in to the function.
so, in following everyones advice, I changed the struct definition to:
TC_ITEM tab = {0};
tab.mask = TCIF_TEXT | TCIF_PARAM | TCIF_IMAGE;
tab.dwState = 0;
tab.iImage = -1;
tab.pszText = (LPSTR)r->name.c_str();
tab.lParam = (LPARAM)r;
tab.cchTextMax = r->name.size() + 1;
this solved the display poblem, so my control is fully operational now.
Thanks for all the help, this board has been great!
Dave
|
|
|
|
|
Glad you got it working But you missed my point about keeping TCITEM structs in a list (or vector, doesn't matter). TCITEM::pszText is a pointer to a char array, and you're storing the pointer without storing what it points to as well. Later on if you try to read/write to a pszText pointer, it will be pointing into freed memory or other data, not the original string.
--Mike--
LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
I have a library consisting of lots of files. I have one single #include file which includes all the relevant header files, depending on the compile platform. However, I would like to shove all the classes that are declared in the library into one namespace, but don't want to have to go through every #include file and put namespace blah {} around the classes and then have to put blah:: in front of every blinking function. Is there a way of grouping a collection of classes and uploading them into a namespace?
|
|
|
|
|
Add a namespace around the includes:
namespace LibraryStuff
{
#include <libheader1.h>
#include <libheader2.h>
...
} You'd only do this in the code that's using the library, the library itself would remain unchanged.
--Mike--
LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Hello, I'm very interesting by Paul Yi Tung, Ooi sujet : "Tracking an object from a live video input".
I would like learn the picture process ... But, I don't now where there are sources files !
Now, I have Visual Studio .NET 2005 ( Beta ... ) and I cant compile this source ... The compilated program ( .exe ) display at screen the pictures ( video ), but, when I select process mode, the MFC program shutdown ...
It's not funny !
Who can help me ?
I'm french ... Sorry, my english is realy bad !
|
|
|
|
|
I want to change the modified time of a file by giving year,month..etc as input.To use SetFileTime() we need ptr to FILETIME structure.I am able to change the modified time to the current time by taking the systemtime.But facing problem to change to other input time.Please help...Thanks.
|
|
|
|
|
Monisankar wrote:
I want to change the modified time of a file...I am able to change the modified time
So what is it that you are having troubles with? Perhaps a code snippet of what you are doing, and the results it is producing, is in order.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
SYSTEMTIME st;
ZeroMemory (&st, sizeof (st));
st.wYear = 1959;
st.wMonth = 1;
st.wDay = 31;
st.wHour = 5;
st.wMinute = 30;
FILETIME ft;
VERIFY (SystemTimeToFileTime (&st, &ft));
VERIFY (SetFileTime (hFile, NULL, NULL, &ft)); /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Dear members of CodeProject,
I want to invite the most experienced coders (C#, VC++, VB, VB.NET, ASP, ASP.NET and all the other technologies) to join the new outsourcing auction site. There is over 5 the most famous sites on the web now (like RentACoder.com, Elance.com, GetAFreelancer.com and other) but our site is absolutely outstanding because it have now and will have in future a lot of functions and features.
Now under the launch of our site we are looking for skilled, experienced and honest developers to join us. You will work directly with customers, NO agencies, NO third party providers. We need teams of developers or very experienced individuals with perfect English (and maybe German) skills.
If you are INDIVIDUAL you MUST have at least 2 years in outsourcing like freelancer (development, working with customers directly, knowledge about full cycle of development, keep in mind deadlines, etc.).
If you are TEAM or COMPANY you must have at least 3 years of experience and 5-15 developers (or designers, or other personal depending on skills) inside of your group.
All the questions and suggestions you may send at rec@modelstyle.com,
Good luck!
|
|
|
|
|
PavelMenshikov wrote:
the most famous sites on the web now (like RentACoder.com,
I think many CPians would characterize RentACoder as infamous, not famous.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I hate those freelance sites....for me it's almost impossible to compete with some of the prices and quotes...
Especially the PHP freelance web sites
It's frustrating being a genius and living the life of a moron!!!
|
|
|
|
|
PavelMenshikov wrote:
rec@modelstyle.com,
ModelStyle look like to Be Model Agency not Programmer Agency .
anywya this is not right forum to post advetisement,you better try posting it in Lounge.
"I Think this Will Help"
[Vote One Here,.....]
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
Help,help ,help
Can anybody pls tell me what is back pointers
and when are they used?
|
|
|
|
|
back pointers are used to reference the owner of an object.
lets say you have an object that contains related objects ( for example, a car contains wheels ); the car class knows that it holds X number of wheels; but by default, the wheels don't know they are contained by the car; they could be contained by a bus or a truck; by adding a back pointer to the wheel class, you can know that the class that contain the wheel is indeed a car or a bus or a truck.
/// really pseudo code ...
class wheel;
class car : public vehicule
{
wheel* m_pWheel1;
wheel* m_pWheel2;
wheel* m_pWheel3;
wheel* m_pWheel4;
};
class wheel
{
wheel ( vehicule* pVehicule ){m_pVehicule=pVehicule};
vehicule* m_pVehicule;
};
...
car::car()
{
m_pWheel1 = new wheel( this; );
m_pWheel2 = new wheel( this; );
m_pWheel3 = new wheel( this; );
m_pWheel4 = new wheel( this; );
}
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks very much for solving my problem
Now i know whom to approach
when i got a problem
Thanks once more
|
|
|
|
|
Hey all,
I'm trying to figure out how to directly write to a device in Windows. Basically, what I'm wanting to do is create an image of a device (specifically, a CompactFlash card that doesn't use a filesystem Windows recognises), store it as a file, modify it and dump it back to the card.
Currently, in version 0.001 of my program, I'm just calling dd for Windows using ShellExecute - this works perfectly, but obviously this isn't exactly acceptable for the final product! (and in the kludgy way I've done it, it locks the whole program and I can't implement a progress bar etc etc)
I'm HOPING it's as easy as using fopen and just treating it like a file from then on (sorry, that's my Unix background speaking)...
Any help would be much appreciated.
|
|
|
|
|
How can i stop and notify new device which isn't installed?
I have been programing following but it doesn't work...
Can somebody tell me how...please
following is my code:
==========================================================
BOOL CSPClientDlg::ConnexantStartStop(DWORD NewState)
{
// scan only Media-Classes
HDEVINFO hDevInfo = SetupDiGetClassDevs((LPGUID)&GUID_DEVCLASS_MEDIA, NULL,
NULL, DIGCF_PRESENT);
if (hDevInfo == INVALID_HANDLE_VALUE){
return FALSE;
}
SP_DEVINFO_DATA DeviceInfoData = {sizeof(SP_DEVINFO_DATA)};
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
BOOL bFound = FALSE;
for(int i=0; SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData); i++){
DWORD DataT;
LPTSTR buffer = NULL;
DWORD buffersize = 0;
while (!SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData,SPDRP_DEVICEDESC,
&DataT, (PBYTE)buffer, buffersize, &buffersize)){
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER){
if (buffer){
LocalFree(buffer);
}
buffer = (LPTSTR)LocalAlloc(LPTR, buffersize);
}else{
return FALSE;
}
}
if(strcmp(buffer,"USB") == 0){
bFound = TRUE;
}
if(buffer){
LocalFree(buffer);
}
if(bFound == TRUE){
break;
}
}
if(bFound == TRUE){
// it can take some time...
CWaitCursor wait;
SP_PROPCHANGE_PARAMS PropChangeParams = {sizeof(SP_CLASSINSTALL_HEADER)};
PropChangeParams.ClassInstallHeader.cbSize =
sizeof(SP_CLASSINSTALL_HEADER);
PropChangeParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
PropChangeParams.Scope = DICS_FLAG_GLOBAL;
PropChangeParams.StateChange = NewState;
PropChangeParams.HwProfile = 0;
if (!SetupDiSetClassInstallParams(hDevInfo,&DeviceInfoData,
(SP_CLASSINSTALL_HEADER *)&PropChangeParams,sizeof(PropChangeParams))){
return FALSE;
}
if(!SetupDiChangeState(hDevInfo,&DeviceInfoData)){
return FALSE;
}
PropChangeParams.ClassInstallHeader.cbSize =sizeof(SP_CLASSINSTALL_HEADER);
PropChangeParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
PropChangeParams.Scope = DICS_FLAG_CONFIGSPECIFIC;
PropChangeParams.StateChange = NewState;
PropChangeParams.HwProfile = 0;
if (!SetupDiSetClassInstallParams(hDevInfo,&DeviceInfoData,
(SP_CLASSINSTALL_HEADER *)&PropChangeParams,sizeof(PropChangeParams))
||!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE,hDevInfo,&DeviceInfoData)){
return FALSE;
}
if(!SetupDiChangeState(hDevInfo,&DeviceInfoData)){
return FALSE;
}
}
SetupDiDestroyDeviceInfoList(hDevInfo);
return bFound;
}
=====================================================
in this code, i want to stop only USBs...
Can someone help me to resolve this problem.thank you
Atsuki
|
|
|
|
|
hi !
I have a program written with MFC. I want it to retrieve some data from a mysql database that i have on my webserver. Can anyone tell me how to do this?
thanks
kane
"Some guys hack just to get themselves a girlfriend.What a pathetic reason huh ?"
http://www.coderkane.com
|
|
|
|
|
Have you looked into accessing it via ODBC using a CRecordset object?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
There is also MySQL++, the C++ wrapper for the MySQL C API, which is what I am using in my current project.
I don't know squat about MFC, but it works great with Win32s so I don't see any reason why you couldn't use it.
link to manual and other resources
http://dev.mysql.com/doc/plusplus/en/4_Tutorial.html[^]
Dave
|
|
|
|
|