|
I need to make my own control that should be a rather complicated list box. But where do I start? Is there any good tutorials for this on the net or books?
Should I inherit from CWnd or CListCtrl? Stuff like that, that I need answers to.
Cheers
|
|
|
|
|
Here is a good place to start
http://www.codeproject.com/combobox/
|
|
|
|
|
Hi,
I have a dialog with a static text control. I want to change it's caption at run time. Despite it having an ID in the .rc file (IDC_STATIC), it doesn't come up in classwizard so i can't map it to a CStatic object and thus use the inherited CWnd::SetWindowText member function to update it's text.
I tried manually adding the mapping with :
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMonemupdDlg)
DDX_Control(pDX, IDCLOSE, m_Close);
DDX_Control(pDX, IDC_STATIC, m_Static);
//}}AFX_DATA_MAP
and defining CStatic m_Static in the header file, in the same place as the ClassWizard created definition for IDCLOSE/m_Close. But although this compiles, I get a debug assertation failure in dlgdata.cpp at line 37.
What am I doing wrong?
I know that I could just use CStatic::Create to create the static text control but i'd far rather have the resource managed in the dialog editor.
Thanks for your help
Jon
|
|
|
|
|
IDC_STATIC is a special identifier: has a value of -1 and it's used to mark controls that are not accessed at runtime. Change it to something else, like IDC_TXT1, and you'll see it in the class wizard.
Anyway, if you just want to change the text in response to some event (e.g. button being pushed), you can always use this:
GetDlgItem(IDC_TXT1)->SetWindowText("new text");
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
ok in my application i have this error message when i try to build my project:
"C:\program files\microsoft visual studio\vc98\mfc\include\afxv_32.h(14): fatal error C1189: #error : WINDOWS.H already included. MFC apps must mot "include <windows.h>
my application is created with mfc appwizard exe, and i have choosen the dialog based option.
So, in my dialog box i have put an button which must access an excel database with ADO method.
so....? idon't know what is happening.
gerald
|
|
|
|
|
Check stdafx.h. Probably you have #include <windows.h> before afxwin.h.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
I like to know how can I get a pointer to the previous document template?
Basically have access to the data of precious document.
Thank
Ehsan Behboudi
|
|
|
|
|
previous document or previous document template? the twoa re very different creatures
if you need a particular doc template you can iterate thru the list using CApp::GetFirstDocTemplate() and CApp::GetNextDocTemplate()
if you need the previous document you can iterate through the list of docs of that type by using pTemplate->GetFirstDocPosition() and pTemplate->GetNextDocPosition() (where pTemplate is a pointer to the doc template for those doc types)
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Hello!
Does anyone know how can we insert two string tables in a dialog based application. And how to load data from each string table.
The string id's in both string tables can be same.
I need it urgent.
|
|
|
|
|
Why do you need two strings with same identifiers? Is this a multi-language app?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Yes it is a multi-language application.
Can u help me plz..
|
|
|
|
|
Create separate resource .dlls for each language, then load appropriate one at runtime. If you're using MFC, check AfxSetResourceHandle function and MFC Technical Note 57 (it's in VC++ help).
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
There are two ways to do this, which way you choose depends on your needs.
1) If you are NT/2000/XP only, then you can simply change the language identifier in VC6 and type a new string. Then, in your app you use SetLocaleID (or something similar, don't have the exact call here) to change which Locale will be the default.
2) If you need to support Win95/98/ME, create seperate resource DLL's for each language and then load the right DLL at runtime. If you're using MFC, you can call AfxSetResourceModule() or something similar (Again, don't have my docs handy) to point to it. If you're not using MFC, then you'll need to specify the DLL's handle when getting the string.
|
|
|
|
|
When I use this function,I get some tousle code.This following is my code.
Anyone can help me and give me some advice?
CInternetSession* cis=new CInternetSession;
CHttpConnection* pHttpCon=cis->GetHttpConnection(_T("192.168.0.17"),INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE,8007);
CHttpFile * pFile;
//pFile=pHttpCon->OpenRequest(CHttpConnection::HTTP_VERB_GET,_T("/a.xml"));
// pFile->SendRequest();
pFile=(CHttpFile *)cis->OpenURL(_T("Http://192.168.0.17:8007/a.xml"),1,INTERNET_FLAG_TRANSFER_ASCII);
CString szSession,szResult("\0");
while(pFile->ReadString(szSession)!=FALSE)
{
szResult=szResult+szSession;
}
//DWORD dwRet;
//pFile->QueryInfoStatusCode(dwRet);
//if (dwRet == HTTP_STATUS_OK)
//{
// pFile->ReadString(szSession);
// }
MessageBox(szResult);
//int n=szSession.Find(_T("Session"));
// if(n==-1)
// MessageBox(_T("Not Find Session"));
pFile->Close();
pFile = NULL;
delete pFile;
pHttpCon->Close();
pHttpCon = NULL;
delete pHttpCon;
cis->Close();
cis = NULL;
delete cis;
|
|
|
|
|
I can see that you use _T(), are you using UNICODE strings?
If you are, it don't work. If you send and receive UNICODE strings, the data you receive is just crap...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
But how can I use the OpenURL() function?Can you give me a sample?
When I try this, I get a error "URL not use a discriminating protocol"
pFile=(CHttpFile *)cis->OpenURL((LPCTSTR)("http://192.168.0.17:8007/a.XML"));
|
|
|
|
|
Thank you.
I have resolved this question by using Function Read() instead of ReadString();P
|
|
|
|
|
OK, I need for my application to catch data in an excel database. So, I know th methode to get data, but when I try to compile my application I have this kind of error message:
"error C2501:'_RecorsetPtr':missing storage-class or type specifier"
what do I have to do to repair this error?
thanks for your help.
Gerald
|
|
|
|
|
> what do I have to do to repair this error?
At least post the line rejected by compiler.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
You have that error because the storage class does not exist. You would need to add a "d" to that storage class for it to find it. The storage class is
_RecordsetPtr
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
What grid does a guru use for manipulating a table(adding,inserting,deleting)?
I use "DBgrid" and "Remote Data" but i dont have a good control of them. For example i dont know how to catch the exceptions like somebody insert a string in a integer field and many more. There is only VB grid documentation and i dont manage VB. There are not many examples too...
If you know VC documentation or source codes about DBGrid,DataGrid, Remote Data or ADO Data let me know, please.
If you integrate the one of the CodeGuru grids in databases (not only for retrieve records) please help me. I can deal with ADO and ODBC.
Whats your advise, dear guru?
Thanks!
|
|
|
|
|
Why not a grid written in C and OleDB/ODBC as DB support? Implement into a DLL a window (not especially an ActiveX), export Register/Unregister from this dll, properties and methods (as every ATL/MFC-like wizard do) as (example):
BOOL
GridCtl_GetColumns(
IN HWND hwndCtl,
OUT PGRIDCOLUMNS **ppColumns
);
etc., implement your own paint for header, lines, columns, cells etc.?
The DB support: you can choose from the myriad of DB interfaces available (starting from ODBC and DB-Library and ending with OleDB, ADO, DAO, Newton binome of A,D and O - - ) and create another dll (or in the same) where you implement the "data source": in the same way, register, unregister, general properties (Server/Source, Catalog/Database etc.), methods/properties (IsBOF, IsEOF, NextRow, Query, Cancel, SetSql, RowCount, GetSql etc.), eventually expose a little rectangle with rewind, back button, in the middle a static with some informations (Connected, Row n Of N etc.) and ending with next/forward buttons (something like: "<< < Row 1 of 10 > >>").
If you need an activex, ok, the ATL object wizard should be a good starting point. Implement what you need (connection points, sinks, events, all the usual stuff).
Frankly, I have seen many controls, from simple windows to ActiveX. But I never seen a grid or a data source to like. So I decided to wrote my controls (including grid) in C. It works, until now.
(RO: Mai pe romaneste: ce faci cu mina ta... )
Cristian 'Sardaukar' Amarie
|
|
|
|
|
I seem to have stubled across my second bug (in about 8 hours worth of using this compiler).
Now, I've always used what I believed to be the standard way of throwing class exceptions (as shown in Stroustrup):
<br />
class AWobbley {<br />
char *m_msg;<br />
public:<br />
AWobbley(const char *msg);<br />
...<br />
<br />
};<br />
<br />
...<br />
<br />
throw AWobbley("AGHRR!");<br />
...<br />
<br />
catch (AWobbley &e) {<br />
... do something with e.m_msg<br />
}<br />
<br />
The problem came up when the exception class stored a dynamically constructed message and, thus, needed a destructor to delete it. In VC++ this destructor is called before the exception handler is entered. This, of course, completely messes up the whole technique.
I haven't yet found a bug report on the Microsoft site. Anyone else with this problem?
Yes, of course there are work arrounds like passing a pointer to a newed object and deleting it at the bottom of the exception handler, but it's ugly and something I wouldn't want to keep for another compiler.
|
|
|
|
|
You need to add the copy constructor to AWobbley and program will behave as expected. If you comment out AWobbley(const AWobbley &a), you'll see two dtor calls and only one ctor - looks like a bug. And the funniest thing is that program doesn't call copy ctor when it is defined.
class AWobbley
{
public:
AWobbley() { printf("def ctor\n"); }
AWobbley(const char *msg) : m_msg(msg) { printf("ctor\n");}
AWobbley(const AWobbley &a) { printf("copy ctor\n"); m_msg = a.m_msg; }
~AWobbley() { printf("dtor\n"); }
void print() { printf("%s\n", m_msg); }
private:
const char *m_msg;
};
void main( void )
{
try
{
throw AWobbley("AGHRR!");
}
catch (AWobbley &e)
{
printf("exception handler\n");
e.print();
}
}
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Now that is weird. I'd say definitely a compiler bug. Thanks for the work arround.
|
|
|
|