|
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.?
|
|
|
|
|
On the Tools menu choose Options. In the dialog options tree select "Startup". Try putting this in for the URL:
http://go.microsoft.com/fwlink/?linkid=45192&clcid=409
The next question is, how to get different URLs? Anyone?
led mike
|
|
|
|
|
Hmmm, can I access any of the compilers from the Text editor? Also, can I combine different languages in one project, or solution? I'm just not sure if there is some sort of toggle between language editors or not...
|
|
|
|
|
Yes, you can mix projects with different languages in the same solution. When you add another project to the solution, you will see the default language (in my case C++), and if you click on "other languages", you will have an opportunity to choose a different language project. If you did not install the other languages, then you will need to modify your installation.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
That is great! I did the Full installation, so it should have loaded all languages. Where is it that one can click on "other languages"? Does this choice happen when I start a new project?
|
|
|
|
|
You go to the File Menu, Got to New and move your cursor to Project. A New Project dialog box will come up with your default language options already expanded. Below that, you should see "other languages". I am using the standard version of VS 2005, by the way.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
How To Load Google Toolbar For Dialog??
Google Toolbar ClsID:{2318C2B1-4965-11d4-9B18-009027A5CD4F}
Code:
bool CShowToolbarDlg::LoadIEToolbar( CString strCLSID )
{
CLSID clsid;
WCHAR wsz[MAX_PATH];
::MultiByteToWideChar(CP_ACP, 0, strCLSID, -1, wsz, MAX_PATH);
HRESULT hr = CLSIDFromString(wsz, &clsid);
if ( hr != NOERROR )
return false;
::CoInitialize (NULL);
IUnknown* puk;
hr = ::CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&puk);
if (FAILED(hr))
return false;
IDeskBand *pdb;
hr = puk->QueryInterface(IID_IDeskBand, (void**)&pdb);
HWND hBand;
if (SUCCEEDED(hr))
{
pdb->GetWindow(&hBand);
if(hBand == 0)
return false;
CWnd *pWnd = CWnd::FromHandle(hBand);
}
m_pReBar = new CReBar();
m_pReBar->Create(this);
CWnd *pWnd = CWnd::FromHandle(hBand);
if(pWnd==NULL) return false;
m_pReBar->AddBar(pWnd,NULL,NULL, RBBS_BREAK);
REBARBANDINFO rbbi;
rbbi.cbSize = sizeof(rbbi);
rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE;
rbbi.cxMinChild = 0;
rbbi.cyMinChild = 10;
rbbi.cx = rbbi.cxIdeal = 250;
UINT nCount = m_pReBar->GetReBarCtrl().GetBandCount();
m_pReBar->GetReBarCtrl().SetBandInfo(nCount-1, &rbbi);
return true;
}
Error:
pdb->GetWindow(&hBand);
if(hBand == 0)
return false;
Why hBand is NULL??
|
|
|
|
|
MyNothing wrote: HWND hBand;
It's not initialized to anything.
John P.
|
|
|
|
|
to questions really, how do i amke the program i've created into an exe that can be run on any pc, secondly how can i make it into a program that can be installed onto other people's pc's. I'm sure it's easy but i'm a newbie, and any help would be much appreciated
|
|
|
|
|
That's called deployment - Lots of info here: Deployment (C++)[^]
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
How about using an installer ?
InstallShield, VISE, NSIS, ...
|
|
|
|
|
|
Look at QSetup Installation Suit
sanket patel
|
|
|
|
|
Hi,
I'm coming up to speed on C++ AddIns (I plan to write one). Having played with a lot of samples, I think I've got a handle on the basic architecture.
I see that it's common to have TWO dlls registered for a given AddIn -- one that seems to be just a bootstrap that tells VS about the other one (the projects are typically called MyAddin and MyAddinControl).
I see it's quite possible to do it all in a single dll, and in fact that's the framework provided by the VS wizard when you create an AddIn. So I'm wondering why people seem to like to split it in two pieces? Is there some advantage to doing that?
Thanks!
DB
|
|
|
|