|
<quote>
Are you calling ShowWindow(hButton, SW_HIDE)?
no, in cBuilder it's Button[idbutton]->visible = false; or colour = red ia
but the problem is the [idbutton] outside the creation void this id doesn't exist.
ia:
void blabla()
{
Button[test] = new TButton(this); \\ now i've got a button called Buttontest
}
void blabla2()
{
Buttontest->colour = red; // now it should change to red
}
instead of changing the colour to red the compiler shouts out "error, this Buttontest doesn't exist"
if i put the change colour into the creation void, than it doesn't change but becomes the defauld property of the button.
<quote>
Do you have code in place to respond to a button click?
that's the problem, i don't know how to do that [newbie]
|
|
|
|
|
wielklem wrote: no, in cBuilder...
Keep in mind that this is a Microsoft-centric forum, hence the VC++/MFC at the top.
wielklem wrote: that's the problem, i don't know how to do that [newbie]
And likely neither do we, unless you happen to find someone else that knows cBuilder.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
i know, but the basics are the same, it's still c++.
if i've got the code or the basic way to work in visual c, than i can translate it into cbuilder.
creating a new button or changing a code-written button is no problem.
so what i need is the basic way to give a new-made button a function or change it's behaviour / apearence.
|
|
|
|
|
wielklem wrote: i know, but the basics are the same, it's still c++.
Not really, but that's an altogether different discussion.
wielklem wrote: so what i need is the basic way to give a new-made button a function or change it's behaviour / apearence.
Check out ModifyStyle() and SetWindowLong() .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Why so many questions, David? How is this guy supposed to get any work done when he has to spend half his day answering questions. At this rate, he'll never get around to using the debugger or reading any documentation.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Touche.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Excellent link!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi
How to get text of menu item in CString.
how can get whole menu item data in MENUITEMINFO structure.
Thanks.
destined to win
|
|
|
|
|
[^], [^], [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi everyone,
I am programming an application which pretends to work under Xp and vista using getAdaptersAddresses function. This function returns code 13 everytime i call it(only in Vista). The following code already works under XP but fails in Vista. I would appreciate any help or tip. Thank you in advance.
{
PIP_ADAPTER_ADDRESSES adapterAddresses = NULL;
PIP_ADAPTER_ADDRESSES adapterAddress = NULL;
DWORD ret = 0;
ULONG len = 0;
len = sizeof (IP_ADAPTER_ADDRESSES);
adapterAddresses = (IP_ADAPTER_ADDRESSES*) malloc(len);
if (adapterAddresses == NULL) {
// Don't care about return value
return INADDR_ANY;
}
// Try to get the size. It is not modified under vista.....
if ((ret=GetAdaptersAddresses(AF_INET, GAA_FLAG_INCLUDE_PREFIX , NULL, adapterAddresses, &len)) == ERROR_BUFFER_OVERFLOW){
// This should happen....
MessageBox(NULL,L"RESERVING",L"LLL",MB_OK);
free(adapterAddresses);
adapterAddresses = (IP_ADAPTER_ADDRESSES*) malloc(len);
if (adapterAddresses == NULL){
return INADDR_ANY;
}
}
// Check return value.
switch(ret){
case NO_ERROR :MessageBox(NULL,L"AdapterAddress OK!!", L"Enter Interfaces", MB_OK);break;
case ERROR_ADDRESS_NOT_ASSOCIATED :MessageBox(NULL,L"AdapterAddress FAILED!!-NO ADDRESS ASSOCIATED", L"Enter Interfaces", MB_OK);break;
case ERROR_BUFFER_OVERFLOW :MessageBox(NULL,L"AdapterAddress FAILED!!-OVERFLOW", L"Enter Interfaces", MB_OK);break;
case ERROR_INVALID_PARAMETER :MessageBox(NULL,L"AdapterAddress FAILED!!- PARAMETERS", L"Enter Interfaces", MB_OK);break;
case ERROR_NOT_ENOUGH_MEMORY :MessageBox(NULL,L"AdapterAddress FAILED!!- NO MEMORY", L"Enter Interfaces", MB_OK);break;
case ERROR_NO_DATA :
MessageBox(NULL,L"AdapterAddress FAILED!!- NO DATA", L"Enter Interfaces", MB_OK);break;
default :
{
LPVOID MsgBuf;
if (FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
ret,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &MsgBuf,
0,
NULL ))
MessageBox(NULL,(LPCWSTR)MsgBuf,L"ERROR ADAPTER 1",MB_OK);
WCHAR aux[100];
wsprintf(aux,L"Len %d - ret %d",len,ret);
MessageBox(NULL,aux,L"data",MB_OK);
}
break;
}
ret = GetAdaptersAddresses(AF_INET, GAA_FLAG_INCLUDE_PREFIX, NULL, adapterAddresses, &len);
// Check return value
switch(ret){
case NO_ERROR :MessageBox(NULL,L"AdapterAddress OK!!", L"Enter Interfaces", MB_OK);break;
case ERROR_ADDRESS_NOT_ASSOCIATED :MessageBox(NULL,L"AdapterAddress FAILED!!-NO ADDRESS ASSOCIATED", L"Enter Interfaces", MB_OK);break;
case ERROR_BUFFER_OVERFLOW :MessageBox(NULL,L"AdapterAddress FAILED!!-OVERFLOW", L"Enter Interfaces", MB_OK);break;
case ERROR_INVALID_PARAMETER :MessageBox(NULL,L"AdapterAddress FAILED!!- PARAMETERS", L"Enter Interfaces", MB_OK);break;
case ERROR_NOT_ENOUGH_MEMORY :MessageBox(NULL,L"AdapterAddress FAILED!!- NO MEMORY", L"Enter Interfaces", MB_OK);break;
case ERROR_NO_DATA :
MessageBox(NULL,L"AdapterAddress FAILED!!- NO DATA", L"Enter Interfaces", MB_OK);break;
default :
{
LPVOID MsgBuf;
// printf("Call to GetAdaptersAddresses failed.\n");
if (FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
ret,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &MsgBuf,
0,
NULL ))
MessageBox(NULL,(LPCWSTR)MsgBuf,L"ERROR ADAPTER",MB_OK);
WCHAR aux[100];
wsprintf(aux,L"Len %d - ret %d",len,ret);
MessageBox(NULL,aux,L"data 2 ",MB_OK);
}
break;
}
// Function continues....
}
|
|
|
|
|
I have solved the issue. It is none related with the code but with iphlpapi.dll file. In windows vista this file is smaller for some reason, and using it instead of the one added by vs2008 (from windows xp) fixes this error.
|
|
|
|
|
Hector_M wrote: In windows vista this file is smaller for some reason, and using it instead of the one added by vs2008
The DLL comes with the operating system, not VS.
What gave you the idea you needed to redistribute it?
I hope you aren't doing that with other system DLLs.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Emmm, sorry there must be some errors in my answer. Of course i know that iphlpapi comes with the operative system, in fact is in windows/system32 directory, what i tried to say is that vs2008 included this file in my setup project, because it detects a dependency with it. So, when i installed my installation package in windows vista i discovered that iphlpapi was quite different from the one in winXP and cause my app to crash, what was amazing for me, since systems should be compatible backwards...although microsoft has its own rules.... .
The only doubt about that is the differences between those files, and i ask myself if the group of functions "GetAdapterInfo" has been removed definitely, and the problems with backwards compatibility.
Apart from that, thanks for answering.
Hector.
|
|
|
|
|
Hector_M wrote: vs2008 included this file in my setup project, because it detects a dependency with it.
Well that is redistributing it, isn't it? Does your
setup place it on the destinatioon machine? If so, that's
wrong, and it should be removed from your setup.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Emmm sorry once again, with "and using it instead of the one added by vs2008 (from windows xp) fixes this error" (on the first reply) i meant that i excluded it from my project, and let the OS look for its own iphlpapi.dll,but in any case, thanks a lot for your answers.
Hector
|
|
|
|
|
Hector_M wrote: ...and using it instead of the one added by vs2008 (from windows xp) fixes this error.
Or masks it.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hallo
i used in my app to open a file by browsing open Dialog box. After that i want to
create a text file in my application directory using '..\\' notation. Like
fp = fopen("..\\MyApp\\Temp\\Something.txt","w");
Can it possible to create a file in my app directory using '..\\' this type of notation.
Thanks
|
|
|
|
|
Sk Mohiuddin wrote: After that i want to
create a text file in my application directory using '..\\' notation
Your notation depends on the current directory. How do you know where it points to at the moment?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Yes you can. But, as already pointed out by sashoalm, there must exist the folder MyApp\Temp inside the application current directory.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for the Suggestion
|
|
|
|
|
I am writing block which throws com exception and i have written code in following way.
GetDate() & SetDate(d) both throws exception.
Date d;
try
{
// Many statements can throws exception
d = GetDate();
SetDate(somedate);
// calculate some "value"
}
catch(_com_exception &)
{
// set value = 0;
}
try
{
SetDate(d); // reset date
}
catch(_com_exception &)
{
// set value = 0;
}
Even if both block throws same exception i cant put them in one try for the reason that in any case either it throws exception or not i want to reset date at the end.
Is this code looks good with consideration of good coding practices?
Thanks,
Perry
|
|
|
|
|
Well, in my opinion it depends on the goal of your app, since at least for me,it is good to make fully diference between every error code, and in your app. it seems that the situations are different, so for me this is good since personally, i hate long "if"/"try-catch" statements.
regards,
Hector.
|
|
|
|
|
I may be wrong, but Exceptions seem to me to be an unexpected error (out of bounds memory, couldn't allocate enough memory, divide by zero), while something like HRESULT return value schemes tend to look for and handle expected errors.
So to answer whether or not using try{}catch{} is good practice, you have to explain (to yourself or to us) why you're using them. Sorry for the generic answer, but coding is all about using the right tool for the job, just like anything else - otherwise you end up in this forum too often.[^]
|
|
|
|
|
I am creating one project in which my client is "MFC dialog based"( "exe" ) and dll is "MFC dll".
In MFC dll there is one dialog box that is access by Client application. This is done with the help of exported function but when in this exported function i use domodal than it crashes and an error message occur
"Unhandled exception".
I dont understand what is the issue ??
Is the problem occur because i am using resource of dll??
Thanks in advance.
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
|