|
|
Look, you make a call to ftp::ftp_StrChr [inside ftp::ftp_FileExists] but this function is not defined [it has no body]. So define that function.
--
======
Arman
|
|
|
|
|
|
hi all!!!
i have already split file by size eg. for window media format file (wmv/wma).
but now i want to split file by play length like suppose i take %age in the edit box
and it will parts that file with all equal size and remaining with the rest.
thanks in advance
|
|
|
|
|
The purpose of splitting is uncertain...
What's the problem? You have the file length and the persentage, so define the split position = (length*percent)/100. Or you wonder smth else?
--
======
Arman
|
|
|
|
|
hi! i've made a custom control button. the problem is when i click the button, the icon "disappears". when i switch to other window and back again to my app, the icon is displayed again. i think it doesnt repaint properly. here's my code in OnPaint(): It only happens in Windows 2000, not in Win XP
void CIconBitmapButton::OnPaint()
{
__super::OnPaint();
CDC* pDC = this->GetDC();
SendMessage(WM_ICONERASEBKGND, (WPARAM) pDC->GetSafeHdc(), 0);
RECT canvasArea;
GetClientRect(&canvasArea);
int iconX = 0;
int iconY = 0;
ICONINFO iconInfo;
GetIconInfo(this->m_hIcon, &iconInfo);
HDC hDC = pDC->m_hDC;
CBitmap* iconBitmap = CBitmap::FromHandle(iconInfo.hbmColor);
CBitmap* maskBitmap = CBitmap::FromHandle(iconInfo.hbmMask);
BITMAP iconSize;
iconBitmap->GetBitmap(&iconSize);
iconX = iconSize.bmWidth;
iconY = iconSize.bmHeight;
// NOTE: icon must be drawn with these coordinates
int buttonX = canvasArea.right/2 - iconX/2;
int buttonY = canvasArea.bottom/2 - iconY/2;
pDC->DrawIconEx(buttonX, buttonY, this->m_hIcon,0,0,0,brush, DI_IMAGE);
// if (m_stretch)
ReleaseDC(pDC);
DeleteDC(hDC);
iconBitmap->DeleteObject();
maskBitmap->DeleteObject();
// if (this->m_hIcon)
}
|
|
|
|
|
Seems there is a problem in last lines of the function. Don not call DeleteDC(hDC); the logic is that you do match a ReleaseDC per GetDC and this is all. Also you are wrapping a C++ object over iconInfo.hbmColor and iconInfo.hbmMask. These CBitmap objects are only temporary wrappers over underlying handles and thus do not call DeleteObject for them.
--
======
Arman
|
|
|
|
|
What I am looking to do is to provide the user (who runs my program) with a list of devices that they can pick from. You can do this with an Open File dialog if you click on "My Computer". What I want to know is how I can set up the dialog before the user opens it to prsent this list. How would you do this in C++? Have you seen it done before?
[IMG]http://i67.photobucket.com/albums/h292/Athono/_help.png[/IMG]
I want one of two (or both) solutions.
#1) I already have a custom File Open dialog program written where I am able to make sure that the user selects a directory and is not allowed to input a filename. Now I just want to know how to set up this estantiated FileOpen class so that it will first come up with the "My Computer" area showing.
OR
#2) I want to create a drop-down menu that only shows the devices for the user to pick from. In other words, just the C drive, the D drive, etc.
|
|
|
|
|
Sounds like you want SHBrowseForFolder
|
|
|
|
|
I made my own Dynamic array holder and now i want to read into it from a file i was wondering if anyone could kind of put me on the right track here is what i have.
struct item
{
char type[16];
char name[16];
unsigned int cost;
unsigned int weight;
};
int main()
{
int size;
string line;
DynArray<item> dline;
ifstream ifl;
ifl.open("items.shp", ios_base::in);
ifl >> size;
while(! ifl.eof())
{
getline(ifl,line);
dline.append(line); //line giving me errors
cout << line << endl;
}
ifl.close();
return 0;
};
I was thinking i might have to make a variable for each of them and then append one at a time. Any suggestions?
|
|
|
|
|
What about serialization [^]?
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.
|
|
|
|
|
hi there,
i'm building a SDI form application and thought it might be good to have a dialog box as a set of alternate controls for a few parameters of that application.. is this possible? i've created the dialog box resource but i'm having some trouble getting them to talk to one another..
for example - the main form contains a few slider controls for parameters and this all works fine, but i also want to be able to control these parameters from a seperate dialog box, and ideally i'd want them to correspond on submission (if moved in the dialog box, the original is updated..) is there any way to link 2 controls to 1 parameter? should i be working with a MDI?
thanks in advance!
|
|
|
|
|
As with any dialog, some member variables linked to the dialogs slider controls in the DoDataExchange should be sufficient. After the CDialog derived class is instantiated, have the view set the dialogs members. Once DoModal returns with IDOK, but before the CDialog derived class goes out of scope, your view code can get the last position of the slider and update its controls accordingly.
/*
Obviously, there will be more to it than this but the basic idea is the same
*/
void CTestsliderView::OnShowDialog()
{
// TODO: Add your command handler code here
CSliderDialog dlg;
dlg.m_nSlider=15;
if (dlg.DoModal()==IDOK) {
TRACE("New Slider pos = %d\n",dlg.m_nSlider);
}
}
|
|
|
|
|
bob16972's idea is good, at the same time u can have "CSliderDialog dlg;" is the member of CTestsliderView class.so that across the view u can access ur dialog very easily.
|
|
|
|
|
thanks alot this looks like it will work for me,
however i've just had a quick look and when i try to set the position of the dialog slider from the view code (ie "dlg.m_nSlider.SetPos(0)) i get an assertion failure with "afxcmn.inl" which breaks at the SetPos function.. have i missed something?
in the dialog code i've set up a member variable linked to the dialog slider with DoDataExchange and i've also used OnInitDialog() to set the range of the slider.. but other than that i think its as above..
thanks in advance
|
|
|
|
|
You don't show code but I bet you're calling SetPos before the dialog is created. You need to do something like what you were shown originally by bob16972
CSliderDlg dlg (this);<br />
dlg.m_nSlider = <value>;
if (dlg.DoModal () == IDOK)<br />
{<br />
}
The actual call to SetPos should be from within the CSliderDlg's OnInitDialog. Also, you need to do something in your CSliderDlg::OnOK to put the position of the slider into the m_nSlider variable. I haven't played with sliders and DDX to know offhand if the DDX does this for you on slider controls.
Judy
|
|
|
|
|
You'll assert because the windows don't exist unless the dialog is modal (I'm not considering modeless since that comes with it's own set of issues). The dialog object does exist and that's where the members come into play.
Make sure the member variables you create are for the value and not the slider control. Notice that the member in the sample is of type int and not CSliderCtrl (You could create one of both so you can get to the control from within the dialog class, just remember not to use it if the dialog window does not exist.) Separate the dialog object from the window and the asserts will make more sense.
Hope that helps
|
|
|
|
|
thanks very much, fairly new to MFC so sorry if that was a bit obvious!
|
|
|
|
|
Hello!
I am wondering, I made a dialog box button and assigned it an ID such as ID_MyDialogBoxButton. Now that I've removed the button and no longer use it, I want to clean up the unused symbol. Is the best way to go into Resource.h and delete the offending #define line? I seem to remember Visual C++ 2005 has a symbol explorer. How to I bring this explorer up? And is this the best way to remove the symbol?
Thanks so much!
Max
|
|
|
|
|
Here's how to delete unused symbols:View | Other Windows | Resource View (to open the resource view)
- R-click the .rc file icon and select
Resource Symbols
- Delete the unused ones
/ravi
|
|
|
|
|
That's cool, didn't know about that and just tried it.
Make a back-up first, or use a revision control system! I just tried this on a scratch project and it flagged something as being in not-in-use when it was, so now it won't compile . No worries here, just wanted to issue the warning.
|
|
|
|
|
Hi,
I made a program which hashes string items in a table. The table has 5 index positions.
When the table is full with string items, the linked list is overwriting the existing string items.
This is my code from Table:
Table::Table(int listSize)
{
size = listSize;
list = new List[size];
}
// hash function
int Table::hash(string item)
{
unsigned int hval, g;
char *str = &item[0];
/* Compute the hash value for the given string. */
hval = 0;
while (*str != '\0')
{
hval <<= 4;
hval += (unsigned int) *str++;
g = hval & ((unsigned int) 0xf << (HASHWORDBITS - 4));
if (g != 0)
{
hval ^= g >> (HASHWORDBITS - 8);
hval ^= g;
}
}
return hval%size;
}
Node* Table::find(string item)
{
int hashValue = hash(item);
return list[hashValue].find(item);
}
Node* Table::insert(string item)
{
int hashValue = hash(item);
return list[hashValue].insert(item);
}
bool Table::isMember(string item)
{
int hashValue = hash(item);
return (list[hashValue].find(item) != NULL);
}
void Table::remove(string item)
{
int hashValue = hash(item);
list[hashValue].remove(item);
}
void Table::print()
{
for(int index = 0; index < size; index++)
{
cout << "Index: " << index << ": ";
list[index].print();
cout << endl;
}
}
The double linked list class:
List::List()
{
head = NULL;
}
List::~List()
{
Node* previousNode;
Node* node = head;
while(node != NULL)
{
previousNode = node;
node = node->next;
delete previousNode;
}
}
Node* List::insert(string item)
{
head = new Node(head, item);
return head;
}
void List::remove(string item)
{
Node* previousNode;
Node* node = head;
while(node != NULL)
{
if(head->value == item)
{
// Link previous node to next node
if(previousNode != NULL)
previousNode->next = node->next;
else
head = node->next;
delete node;
break;
}
previousNode = node;
node = node->next;
}
}
Node* List::find(string item)
{
Node* previousNode;
Node* node = head;
while(node != NULL)
{
if(head->value == item)
return node;
previousNode = node;
node = node->next;
}
return NULL;
}
void List::print()
{
Node* node = head;
if(node != NULL)
{
cout << node->value << " ";
node = node->next;
}
cout << endl;
}
Node class:
Node::Node(Node* n, string s)
{
next = n;
value = s;
}
The Table with the hashed string items im trying to make should look for example like this:
Index 1: string23, string5, string11, etc...
Index 2: string9, string1,
Index 3: .......
The table has to be balanced a bit.
Can somebody tell me what is going wrong in my double linked list?
Thanks in advance!
|
|
|
|
|
Have you tried to debug it? Perhaps single stepping through the insert function when it overwrites?
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Hi cp9876,
I've done debugging and searching the net.
|
|
|
|
|
I am not new to programming, though I am new to programming for windows and Visual Studio 2005. With that in mind, when I first loaded up Visual Studio 2005, and then started it, I was asked which environment I wanted to start in. I responded with C++. So now, everytime I start it up, the Start Page is giving me a bunch of C++ information. Let's say I would like to do some programming in Visual Basic, or C#. How do I change back and forth between VB, C#, and C++, etc.?
|
|
|
|