|
CStatic * pStatic = new CStatic[10];
You could also create pointers and push them into a vector.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I am working with V C++ Help Workshop. I've created the .rtf file (several times) and recompiled (several times), deleted the .hlp file and recompiled (several times), and I still see pages/topics that are NOT in the .rtf file. Almost as though Help Workshop is not recompiling.
All help appreciated
Richard
|
|
|
|
|
Hi,
The Operating System is Window 2000 and I have support for Arabic and English. Now I want to write an application in VC++ whose interface is in arabic.
eg I want that in "Edit Box" the value should displayed
in Arabic format.
and the Caption of buttons is in arabic too.
I am new commer in this "multi-language" development so if some-one knows any thing in this regards. Kindly response me.
Have a nice wishes for my helper.
|
|
|
|
|
I have a lot of experience in Cyrillics Idioms.
I worked in Hebrew and Arabic, and in English, Spanish, Portugesse, Russian, France, etc.
What do you Need?
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Which variable is for the Parent-Window in MFC? (CWnd)
Here is the problem: Parameter 5
Test.Create("Static","Test",WS_VISIBLE | WS_CHILD, rect, Parent, IDC_X, NULL);
or how can I create a Control manually in MFC?
|
|
|
|
|
try
m_hWnd
or
GetParent()
|
|
|
|
|
m_hWnd does not work...
and GetParent causes an Error
|
|
|
|
|
If you want to create a child control, the parent window must exist.
If you want to create a control in a CDialog, you must do it in the OnInitDialog(), after calling de default OnInitDialog()
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
Test.Create("Static","Test",WS_VISIBLE | WS_CHILD, rect, m_hWnd, IDC_X, NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
of in the OnInitialUpdate() if you want to create a control in a CView
void CMyView::OnInitialUpdate()
{
CView::OnInitialUpdate();
Test.Create("Static","Test",WS_VISIBLE | WS_CHILD, rect, m_hWnd, IDC_X, NULL);
}
|
|
|
|
|
I'm sure this problem must have been solved many moons ago, and my newbieness is just holding me back. I am trying to draw a couple of buttons on a dialog using Win32, that contain up and down arrows. I can use WM_SETFONT, to set the Symbol font, but how do I set the character to appear on the button? If I could use a bitmap button that would be OK, but I cannot use MFC. Any ideas anyone?
Any help would be gratefully appreciated.
ChrisP
|
|
|
|
|
Is WM_SETTEXT message what you're looking for? Maybe I haven't understood your problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
My Class is using some bitmap, there not very big I'd like that only one instance of the bitmap exist for all instance of my class.
In java it's static member of the class, in MFC I've try to do
Class MyClass: public CWnd
{
...blablabla...
private:
static CBitmap MyBitmap;
...blablabla
}
and the linker said
MyClass.obj :error LNK2001:unresolved external symbol "private: static class CBitmap MyClass::MyBitmap" (?MyBitmap@MyClass@@0VCBitmap@@A)
so what is wrong?
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
|
|
|
|
|
in a .cpp file, you need to have:
#include "MyClass.h"
CBitmap myClass::MyBitmap;
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
thanks, it was easy;)
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
|
|
|
|
|
What is the difference between
[code]
char something[64];
[/code]
and
[code]
char something = new char[64];
...
delete something
[/code]
I only know that the memory is allocated different, but don't know exactly how.
Is there one initialization which is better or faster?
thanks for your help
|
|
|
|
|
in a function
MyFunction()
{
char something[64];
[code]
}
the memory is static with the function itself, it's mean that window allocate some memory for the function and that include this 64 char
it's why we don't have to bother to delete this memory, it' will be flushed whit the function itself.
function2()
{
[code]
char something = new char[64];
...
delete something
[/code]
}
this way you call a function who call window, windows allocate memory and return a pointer to this memory. in each case the memory is allocated by windows but in one case it is allocate whit (and for) the function and in the other case it is allocated dynamicaly. In fact the when you start you'r program the something[64] is allocated. And when you close you'r program it is desallocated so it is faster because it is allocated one time, and in the other case it is allocated each time you call this function.
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
Le rêve est la seule chose vraiement réelle et vraiement consistante
|
|
|
|
|
You may try something very funny
class MyProjectView :public CView
{
...
public:
CString strTemp
...
}
void Function1(int paramControl)
{
char Something[64]
if(paramControl == 1){
sprintf(something,"test of allocation memory");
}
else{
strTemp.Format("%s",strTemp);
}
}
then somewhere call two time this function IN RELEASE (Debug mode do some initialisation and it will never work) like this
Function1(1);
Function1(2);
dc.TextOut(50,50,strTemp);
and you will be able to see test if allocation memory, because the space in memory for the function have never change the string is still there if you don't overwrite so you can "read" in the string what you have done before
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
|
|
|
|
|
heuuuuu, soory it's false, in each case the memory is allocated on the stack. So don't read what I've said before, it's false. each of them are near to be the same. Sorry for the error.
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
|
|
|
|
|
function2()
{
char* something = new char[64];
...
delete [] something;
}
1- New is returning a pointer !
2- Delete has to delete the array so use []
wimel
|
|
|
|
|
Differences:
char something[64];
An array of 64 elements, each of sizeof(char) bytes, is allocated on the stack and given the name "something". This is extremely fast, as it only requires the stack pointer to be moved down by 64 bytes. When the function returns, the stack is automatically cleaned up, which includes this array. The drawback is that number of elements in the array (64 in this case) must be predetermined at compile time. In fact, the compiler checks that this value is constant.
char* something = new char[64];
delete [] something;
An array of 64 elements, each of sizeof(char) bytes, is allocated on the heap and returned as a pointer which is given the name "something". This is typically a slower operation since the heap manager spends more time managing its available space for all dynamic allocations. It also requires that the programmer explicitly tell the heap when the memory is no longer needed (by calling delete). The benefit is that the program can set the size of the array (64 in this case) at run time. In other words, the value can just as well be an integer variable.
Regards,
Alvaro
|
|
|
|
|
With thanks to Michael Butler, I've figured out where my ATL project is dying. I have added four fields to my database. They are being populated correctly. Previously, retrieved my values like this:
_RecordsetPtr records = NULL;
records.CreateInstance(__uuidof(Recordset));
try
{
records->CursorType = adOpenStatic;
records->CursorLocation = adUseClient;
records->Open("SELECT * FROM FileDatabase",
_variant_t((IDispatch*)m_Connection, true), adOpenKeyset, adLockOptimistic,
adCmdUnknown);
}
catch(...)
{
}
records->MoveFirst();
vector<ISAFileEntry*> vecDatabase;
do
{
CComObject<CSAFileEntry>* pFileEntry = NULL;
CComObject<CSAFileEntry>::CreateInstance(&pFileEntry);
if (pFileEntry)
{
FieldsPtr spFields = records->GetFields();
string s = (bstr_t) spFields->Item["FileName"]->Value;
for (string::iterator it = s.begin(); it != s.end(); ++it)
if (*it == '?') *it = '\'';
pFileEntry->m_FileName = s.c_str();
pFileEntry->m_FileLength = spFields->Item["FileLength"];
pFileEntry->m_DownloadCount = spFields->Item["TimesDownloaded"];
pFileEntry->m_LastModified = spFields->Item["LastModified"];
but since adding four more fields, I find all my numeric values are being read a 0, although Access show me real values have been stored.
Changing to this:
string s = (bstr_t) spFields->Item["FileName"]->Value;
for (string::iterator it = s.begin(); it != s.end(); ++it)
if (*it == '?') *it = '\'';
pFileEntry->m_FileName = s.c_str();
pFileEntry->m_FileLength = spFields->Item["FileLength"]->Value;
pFileEntry->m_DownloadCount = spFields->Item["TimesDownloaded"]->Value;
pFileEntry->m_LastModified = spFields->Item["LastModified"]->Value;
pFileEntry->m_Frames = spFields->Item["Frames"];
pFileEntry->m_Seconds = spFields->Item["Seconds"];
pFileEntry->m_Width = spFields->Item["Width"];
pFileEntry->m_Height = spFields->Item["Height"];
Works for my old values ( I added ->Value to them ), but my new values are still 1, and if I add ->Value to them, it crashes in the first iteration. Can anyone suggest what might be the problem ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Which "field" does it crash on? Do the names match the field names in the database? Do they all cause the problem or can you rem some out and it works?
I'm old fashioned and access my fields by position rather than name
variant_t vt;
vt = m_pRecordset->Fields->GetItem(variant_t((short)4))->GetValue();
Michael
|
|
|
|
|
Any of the four I've added, I've tried them all. Yes, the fields are spelled right, I've checked a bajillion times.
The following code is how the information got put into the database in the first place, and it's there and fine.
spFields->Item["FileName"]->Value = (bstr_t) temp;
spFields->Item["FilePath"]->Value = (bstr_t) bstrPath;
spFields->Item["FileLength"]->Value = (*it)->m_FileLength;
spFields->Item["LastModified"]->Value = (*it)->m_LastModified;
spFields->Item["TimesDownloaded"]->Value = (long)0;
spFields->Item["Frames"]->Value = lFrames;
spFields->Item["Seconds"]->Value = lSeconds;
spFields->Item["Width"]->Value = Width;
spFields->Item["Height"]->Value = Height;
What I don't get is how come it crashes when I add ->Value, otherwise it just returns 1 ? I mean, I know ADO crashes at the drop of a pin and gives you no debugging help, but still.
I don't know how to access by position ( and I'd really like to make this work both ways if I can ), because the whole point of this project is to learn more ATL and some ADO. Please ellucidate.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Well, ADO isn't something I've done a lot with so it could be a case of the blind leading the blind
the spFields collection has a Count property
long nRecordCount = pRst->Fields->Count
how many fields does it say your recordset has?
you could try looping through a record like below and see if it displays all your data (I've hacked this from one of the platform sdk samples)
FieldPtr pFld = NULL;
_variant_t vIndex;
pRst->MoveFirst();
long limit = 0;
limit = ((pRst->Fields->Count) - 1);
for (short iIndex = 0; iIndex <= limit; iIndex++)
{
vIndex = iIndex;
pFld = pRst->Fields->GetItem(&vIndex);
printf("Field %d : Name = '%s', ", iIndex,
(LPCSTR)pFld->GetName());
_variant_t FldVal = pFld->GetValue();
}
|
|
|
|
|
I've solved it, thanks. I read my recordset in like this:
_RecordsetPtr records = NULL;
records.CreateInstance(__uuidof(Recordset));
try
{
records->CursorType = adOpenStatic;
records->CursorLocation = adUseClient;
records->Open("SELECT * FROM FileDatabase",
_variant_t((IDispatch*)m_Connection, true), adOpenKeyset, adLockOptimistic,
adCmdUnknown);
}
catch(...)
{
}
and if the database file in empty it crashes big time. Do you know why that might be ? Anyhow, as a result the first record is a dummy record. I needed to reread some ADO stuff to get clear in my mind what I was manipulating, then I checked the VARIANT coming back from ->Value and found it was VT_NULL, because when I added those four fields, I didn't add dummy values for the dummy record.
I'd love your insight on my empty DB problem though, and on accessing values by position, if you don't mind.
Thanks for the help.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
|