|
i'm wondering how can i set the text of the cell in the datagrid control(microsoft datagrid control, version 6.0(oledb))in my dialog project? i don't have any database source, i just wanna show some text in those grids.
anybody knows? thanks
|
|
|
|
|
If you don't have any datasource it is better to use other grids like flex grid or grids in CP.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
How do I code it so that when a button is press the data on the ComboBox randomize? Please help this newbie programmer.
|
|
|
|
|
Let's say the button is called IDC_BUTTON1
So i guess by now u should know how to do a event for IDC_BUTTON1? Hook on the msg BN_CLICKED.
So let's say you have assigned the combobox to a variable called m_comboBox. This can be done thru class wizard.
You would get
void ClassName::OnButton1
{
m_comboBox.AddString("....");// Your random data
}
Hope this helps.
|
|
|
|
|
I'm sorry, perhaps I didn't explained in detail what I want to achieved. Say my combobox have 5 data entries (properties -> data)
data1
data2
data3
data4
data5
When you press the button, it pick one of those entries and make it the display entry.
|
|
|
|
|
Generate a random number between 0 and CComboBox::GetCount() - 1
Now use CComboBox::GetLBText() on this random number.
Is that what you wanted? Now each time you get a random entry from the combo box
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
|
|
|
|
|
To generate random numbers, use the srand(time(NULL)) to seed the generator.
Then use rand() to get a random number between 0 and MAX_INT (4 billion or so).
To scale this massive range down to that of your listbox, use this formula:
rand() % listbox.ItemCount (or whatever the property is)
That will generate a number between zero and listbox.ItemCount - 1.
You +/- and constant value if you need to shift the lower limit or use rand() % (listbox.ItemCount + x) to shift the upper limit.
|
|
|
|
|
This will be my last time asking, please try to help me this last time.
rand() % listbox.ItemCount
I understand that, but say I have a combobox name IDC_COMBO1, how do I tell its name to use inside my codes?
|
|
|
|
|
To assign a value to the Combobox use the Class Wizard. The steps to do this are:
1. bring up the class wizard (menu VIEW--> ClassWizard).
2. Go to the Member Variables tab.
3. Select the IDC_COMBO1 control ID and them press the ADD VARIABLE button.
4. Give the variable a name, set category to VALUE and press OK.
|
|
|
|
|
I am in the process of converting several applications writting in a combination of Borland Builder 4/5 and Borland C++ to Microsoft Visual C++
Does anyone have any experience doing this and if so, have any suggestions or offers of advise on where and how to start? Web sites, tech guides, books etc. I would be most appreciative!
|
|
|
|
|
I've converted some code from Borland C++ 5.01 (not Builder) to VC++. Most was easy but had to learn STL and convert all code that used Borlands BIDs containers to STL. Also helps to know VC++'s IDE and little things like why and how to use a stdafx.h file, what includes to use for MFC stuff, the differences between the C++ runtime library versions i.e. the difference between #include <iostream.h> or #include <iostream>.
Also, I did not convert over any of the OWL code to MFC. I still have to learn MFC but it doesn't seem that hard and I've had some minor exposure to it. I suggest a complete rewrite of any of Borland's windows code to MFC.
If you have any specific problems you encounter you can send me an email and I'll try my best to answer.
John
|
|
|
|
|
Can we show a Docking ToolBar on Dialog? i have code to show it on SDI but this dont works for the dialog.
IF u know plz give me the piece of code or tell me the way how to do this?
Thanx
|
|
|
|
|
Hi all, I have some quick fire questions that I would love to know the answers to, so please reply even if you only know one or two, or even have an idea.
1.) How do you go about assigning the 6 char string "Arial" to the LOGFONT.lfFontName property? I keep getting an error about can't convert from char [6] to char [32]?
2.) Is the only way of displaying text with DirectX by use of GDI's HFONT and TextOut methods having retrieved a DC from the surface the text is to go to?
3.) Is it normal to create a HFONT based on the newest LOGFONT spec using CreateFontIndirect() and delete it using DeleteObject(hFont) after the desired text has been displayed. Or is better to create multiple HFONTs for differing texts? Basically is there a time penalty for creating/deleting HFONTs?
4.) How do I get the current screen resolution? At the moment I am using the EnumDisplayModes() with my own callback function. Could I use this to find it?
5.) Is there anyway of using a reference to a structure to save me typing out the structure name when accessing its properties? so that:
MYSTRUCT hello;
hello.name = "hello";
hello.width = 1;
hello.height = 2;
-------------------
MYSTRUCT hello;
*using* hello;
name = "hello";
width = 1;
height = 2;
*end* hello;
-------------------
Thanks for getting this far, hope you can answer some of the questions. Cheers all,
Alan.
P.S. My condolences to all fellow England and USA football fans who saw their teams go out in todays matches .
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Alan Chambers wrote:
hello.name = "hello";
1. you can't do this in C/C++. hello.name isn't a CString object, it's just an array of characters. so you have to do this : strncpy(hello.name, 32, "Arial");
4. use GetDeviceCaps
5. nope, not in C/C++
-c
Garbage collection, making life better - for weenies!
|
|
|
|
|
Thanks for the reply Chris, your answers worked a treat. Sorry I didn't get back to sooner, but I went to bed straight after I posted the questions. I am just wondering how to pull out the system and graphics card name, clock speed, RAM etc.? I might find this information useful. I know you can get some of them through enumeration but this seems an awfully long way to go about getting information on the current spec.
Again my thanks to you Chris.
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
I have a local COM server that wraps a 3rd party API. The API contains open and close calls that require significant time. Any number of interactive processes will create and instance of the COM object. So, I set up the local server to perform the open when the app starts and close when the app exits.
This allows users to connect, perform calcualtions and disconnect from the COM object without the overhead of the open and close calls. This produced a performance improvment of about 4000:1.
This solution is only effective if the users connect to the same local server. This is my registration code:
hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
REGCLS_MULTI_SEPARATE | REGCLS_SUSPENDED);
From my reading of MSDN, this looks like I should get one and only one .exe running. What seems to happen is somewhat different. I created a test harness to try it out. I can run many instances of the test harness, while only one instance of the .exe is launched. So far, so good. This is exactly what I want. If I then run the production application while the test harness is running, I get a second instance of the local . I can run multiple instances of the production program without any more instances being launched. The production app
uses CoCreateInstance to acquire and interface and releases it when finished.
Ideally, I would like to start the local server independentaly of the any application that uses it and have client apps use the already running .exe. I tried creating an instance of the COM object in the _twinMain of the local server, but that had no effect.
Any ideas? Suggestions? Solutions? Bad advice?
Thanks in advance for any responses.
|
|
|
|
|
Couple of bluffs here...;)
Go for 'Win32 Service' instead of 'LocalServer'. Will solve all the problems!
Just to keep LocalServer running, Fool it! Set the event (hEventShutdown) manually when you want to close the app and dont set the it on
CExeModule::Unlock(). I'm not sure this is the correct approach.
Thanks,
Ramu
|
|
|
|
|
Do you have control over the local COM server, if so why don't you just declare it as a singleton?
|
|
|
|
|
Thanks for the reply. I'm not familiar with singleton's. Can you refer me to a source? I looked up singleton in MSDN, what I found didn't seem to apply.
|
|
|
|
|
Hi,
I just got a project about mutimedia network.
So ask some question about...
How to transfer a realtime video or audio.
What protocol support ?
And the best Encode method fo Audio & Video?
|
|
|
|
|
this doesnt have much to do with coding in c++ does it? maybe you should try a search engine, im sure you will find more information on statistics involved with audio/video compression somewhere else.
-dz
|
|
|
|
|
Try to take a look the site:
http://www.banasoft.net/AVPhone.htm
|
|
|
|
|
I am using a template class and everyithing works fine until I try to break my code into multiple files. Here is a minimal test case that demonstrates my problem. I am using Visual C++ 6 SP 5 Window XP.
******Solved*************
Visual C++ 6 requires that the implementation and declaration of a template reside in the same file. I can either put everything in the .cpp file or the .h but it has to be in one file.
//Onefile.cpp
#include <vector>
#include <iostream>
using namespace std;
template
class Test
{
public:
// constructors
Test(int size);
~Test() {};
// opertors
T & operator[](int offset) { return itsVector[offset];}
Show();
vector itsVector;
int itsLength;
};
template
Test::Test(int size)
: itsLength(size), itsVector(size)
{
for (int i = 1; i itsVector = i;
}
template
Test::Show()
{
for (int i = 1; i < itsLength; i++)
cout << itsVector[i] << ((i == itsLength-1) ? ('\n') : (','));
}
int main()
{
Test v(4);
v.Show();
v[1] = 9;
v.Show();
return 0;
}
This compiles links and executes just fine. Here is the problem.
//Test.h
#include <vector>
#include <iostream>
using namespace std;
template
class Test
{
public:
// constructors
Test(int size);
~Test() {};
// opertors
T & operator[](int offset) { return itsVector[offset];}
Show();
vector itsVector;
int itsLength;
};
//test.cpp
#include "Test.h"
template
Test::Test(int size)
: itsLength(size), itsVector(size)
{
for (int i = 1; i itsVector[i] = i;
}
template
Test::Show()
{
for (int i = 1; i < itsLength; i++)
cout << itsVector[i] << ((i == itsLength-1) ? ('\n') : (','));
}
//main.cpp
#include <iostream>
#include "Test.h"
using namespace std;
int main()
{
Test v(4);
v.Show();
v[1] = 9;
v.Show();
return 0;
}
When I try to build I get the following linking error.
main.obj : error LNK2001: unresolved external symbol "public: int __thiscall Test::Show(void)" (?Show@?$Test@H@@QAEHXZ)
main.obj : error LNK2001: unresolved external symbol "public: __thiscall Test::Test(int)" (??0?$Test@H@@QAE@H@Z)
Debug/TestTemplate.exe : fatal error LNK1120: 2 unresolved externals
All the errors disapear if quit using templates.
Does anyone know what I am doing wrong?
|
|
|
|
|
Well, your syntax for using templates is wrong. The template declaration is as follows:
template<class mytype, ...>
class MyClass
{
...
This allows you to use a type called mytype or whatever. The class' member functions should be declared as follows:
template<class mytype, ...>
MyClass<mytype, ...>::MemberFunction
Finally, declare instances of the template class like this:
myClass<type (int, class, CString, whatever)> myVar;
This is the worst explanation of template syntax ever. You should read the MSDN documentation of templates. I'm surprised the code got through the compiler.
|
|
|
|
|
it's because everything between a pair of tags, <>, is interpreted as an html tag and therefore remove cause he forgot to turn off html interpretation.
|
|
|
|