|
gordon3056 wrote: is that just a quirk of their system?
Nah - that's how it was being used before the C++ ISO Standard took place (in 1998). However, I do recommend using a more recent compiler.
|
|
|
|
|
im not sure about that.Im using codeblocks btw,quite ez to use ^_^
|
|
|
|
|
I think its a tribute to The Code Project members that I an absolute beginner can get any help at all. Thank you
|
|
|
|
|
Hello,
I am trying to use this control in a toolbar. For the most part the code works. However, I am running into this odd problem that I am getting partial text back when I call GetText.
The app requires that when I click a different button in the toolbar, I check the combo box and retrieve the text from it for processing. That is when this bug surfaces. The last character is getting truncated. If I retrieve the text in response to the Enter key handler for the combo box, I get the full text using the same GetText call.
Here is the code...most all of it is lifted from the samples.
CObList listButtons;
if (CMFCToolBar::GetCommandButtons(ID_EDT_FIND_NDC, listButtons) > 0)
{
for (POSITION posCombo = listButtons.GetHeadPosition();
pSrcCombo == NULL && posCombo != NULL; )
{
CMFCToolBarComboBoxButton* pCombo = DYNAMIC_DOWNCAST(CMFCToolBarComboBoxButton, listButtons.GetNext(posCombo));
if (pCombo != NULL) pSrcCombo = pCombo;
}
}
if (pSrcCombo != NULL)
{
ASSERT_VALID(pSrcCombo);
LPCTSTR lpszSelItem = pSrcCombo->GetText();
...
}
So if the combo box has the text '1234567890', I am getting back '123456789' in one case, and '1234567890' in another case, depending on whether I press the other button or press the Enter key.
Has anyone encountered this, and can someone suggest a solution?
Thanks for your time.
|
|
|
|
|
I just encountered the same problem here!
No solution so far.
It is so frustrating to work with this feature pack...
|
|
|
|
|
Yes, I finally got frustrated enough to think up alternatives. I had already coded to find the CMFCToolbarComboBoxButton object (Code from MSDN actually), so now I went ahead and code along the following lines:
if (pSrcCombo != NULL)
{
ASSERT_VALID(pSrcCombo);
CMFCToolBarComboBoxEdit *pEdit = (CMFCToolBarComboBoxEdit *) pSrcCombo->GetEditCtrl();
if (pEdit)
{
CString strSelItem=_T("");
pEdit->GetWindowText (strSelItem);
pSrcCombo->AddItem (strSelItem);
...
}
}
Using the Edit Control seems to have solved the problem for me. At the MFCToolbarComboBoxButton level, there is no option for a fix that I have found. Perhaps subclassing the control and intercepting the GetText() call may work, but I have not tried it.
modified on Tuesday, October 20, 2009 4:07 PM
|
|
|
|
|
At least this works for me:
In the Code, where a character is truncated replace the call to pSrcCombo->GetText() with something like this:
CComboBox* a_pComboBox(pSrcCombo->GetComboBox());
ASSERT(a_pComboBox);
CString a_strAddressTextInCombo;
a_pComboBox->GetWindowText(a_strAddressTextInCombo);
Maybe in your code you have to distinguish somehow where the call comes from...
Or you could try if the above code works for both scenarios.
Hope I could help,
Patrik
|
|
|
|
|
Yes, a code sample in the MSDN website gives details on how to identify the control that you are using.
CMFCToolBarComboBoxButton* pSrcCombo = NULL;
CObList listButtons;
if (CMFCToolBar::GetCommandButtons(ID_EDT_FIND_NDC, listButtons) > 0)
{
for (POSITION posCombo = listButtons.GetHeadPosition();
pSrcCombo == NULL && posCombo != NULL;)
{
CMFCToolBarComboBoxButton* pCombo = DYNAMIC_DOWNCAST(CMFCToolBarComboBoxButton, listButtons.GetNext(posCombo));
if (pCombo != NULL && CMFCToolBar::IsLastCommandFromButton(pCombo))
{
pSrcCombo = pCombo;
}
}
}
|
|
|
|
|
My problem is similar to the one described here:
http://www-01.ibm.com/support/docview.wss?rs=1079&context=SS2KS6&dc=DB520&uid=swg21230924
In our application we have DLL that is used to write information to Event
Log. Problem is when I need uninstall/upgrade our application this DLL is
often locked after our application is shut down and it requires computer reboot which is undesirable.
For what it's worth - our application is a service. All other .DLL/.EXE files are successfully deleted by uninstall after service is stopped. Or they can be deleted manually if service is stopped.
I know there is a way to unlock/delete this file because this is what
Unlocker application does (http://ccollomb.free.fr/unlocker/)
Does anyone have any ideas on how this is achieved using Windows API?
modified on Friday, September 11, 2009 11:30 AM
|
|
|
|
|
JoeSchmoe007 wrote: Does anyone have any ideas on how this is achieved using Windows API?
How about shutting down your application?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
File is still locked after application is shut down. I edited original post to reflect that. For what it's worth - our application is a service.
|
|
|
|
|
JoeSchmoe007 wrote: File is still locked after application is shut down.
Then some other process is using it, or your application is still running.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
You can use Process Explorer (run it without installation wrom live sysinternals site[^]) to find out which process is holding your file.
|
|
|
|
|
There is a way to forcibly close handles - because Process Explorer can do it.
However, in this situation, you should use MoveFileEx[^] with the MOVEFILE_DELAY_UNTIL_REBOOT flag and a NULL destination filename and Windows will perform the file deletion at the next boot time, before any applications have started to lock the file.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Just close the handle remotely (classic and official method, Win32 (news://comp.os.ms-windows.programmer.win32) since 90's..)
|
|
|
|
|
Hmm guys,is it possible to display number1+ number2+number3?
Eg,if a program prompts a user to input 3 numbers,N1,N2 and N3,is it possible for the program to display N1+N2+N3?As far as i know,we can use a while loop to straight away give us the final answer for N1+N2+N3.
To make it clear,if i input 5 as N1,10 as N2 and 15 as N3,can we make the program display
"total=5+10+15=30" instead of "total=30"?
Can someone guide me on this. xD
|
|
|
|
|
UKM_Student wrote: As far as i know,we can use a while loop to straight away give us the final answer for N1+N2+N3.
That would be the wrong thing to use.
UKM_Student wrote: To make it clear,if i input 5 as N1,10 as N2 and 15 as N3,can we make the program display
"total=5+10+15=30" instead of "total=30"?
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Erm yeah that was a response to my earlier question,what about this one
This question is asking whether can we display the value(s) we take and then adding them up instead of getting a final answer right away o-o
|
|
|
|
|
UKM_Student wrote: Erm yeah that was a response to my earlier question,what about this one
The same response applies. You can have multiple values for a single cout statement.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Erm im not trying to display exactly the numbers lol.Go see the program i wrote in the other page xD
|
|
|
|
|
why is it wrong?For eg.
#include<iostream>
using namespace std;
int main()
{
int total=0,count=0,number;
while(count<5)
{
cout<<"Input 5 numbers.";
cin>>number;
total=total+number;
count++;
}
cout<<"Total is "<<total<<endl;
return 0;
}
From here we can see that the compiler adds up all the 5 numbers.My question is how should i put it so it would display" total: N1+N2+N3+N4+N5=XX "instead of adding all the numbers up then display "total:XX"
|
|
|
|
|
UKM_Student wrote: why is it wrong?
Because you wanted to use a while() loop to sum N1 , N2 , and N3 . Given:
int N1, N2, N3;
while ()
{
} How would that work?
UKM_Student wrote: cout<<"Input 5 numbers.";
This should probably go outside the while() loop.
UKM_Student wrote: My question is how should i put it so it would display" total: N1+N2+N3+N4+N5=XX "instead of adding all the numbers up then display "total:XX"
Given that you are not saving number each time through the loop, you can't.
Consider:
int count = 0, number[5];
while (count < 5)
{
cin >> number[count];
total += number[count];
count++;
}
cout << endl << "total: ";
count = 0;
while (count < 5)
{
cout << number[count];
if (count < 4)
cout << '+';
}
cout << '=' << total;
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Erm i tried running ur program but it was an infinite loop o.o
and whats the meaning of number[5]?I don't think that part is yet of my lvl(i just started C++ for less than 2 months :P)
|
|
|
|
|
See my last answer to your previous question. You really need to study the C language further in order to understand some of the answers given here. Most of the people providing answers here are assuming that you have a basic knowledge of all C language constructs; your supplementary questions make it clear that you have not.
This is not a criticism of you (we all had to start somewhere), rather advice on how to get to the place you want to be.
|
|
|
|
|
Well,i just started learning it in less than 2 months,ie about 8 hours of C++ programming only and the lecturer already gave us such homework,so...
|
|
|
|