|
CString ReadLongName(const char *pszFile)
{
CString csOutName;
static char lpszLongName[256];
unsigned i;
char namebuf[255];
FILE* fp;
unsigned short numNames;
long curseek;
unsigned cTables;
sfnt_OffsetTable OffsetTable;
sfnt_DirectoryEntry Table;
sfnt_NamingTable NamingTable;
sfnt_NameRecord NameRecord;
lpszLongName[0] = '\0';
if ((fp = fopen (pszFile, "rb")) == NULL)
{
return csOutName;
}
fread (&OffsetTable, 1, sizeof (OffsetTable) - sizeof(sfnt_DirectoryEntry), fp);
cTables = (int) SWAPW (OffsetTable.numOffsets);
for ( i = 0; i < cTables && i < 40; i++)
{
if ((fread (&Table, 1, sizeof (Table), fp)) != sizeof(Table))
{
return csOutName;
}
if (Table.tag == tag_NamingTable)
{
fseek (fp, SWAPL (Table.offset), SEEK_SET);
fread (&NamingTable, 1, sizeof (NamingTable), fp);
numNames = SWAPW(NamingTable.count);
while (numNames--)
{
fread (&NameRecord, 1, sizeof (NameRecord), fp);
curseek = ftell(fp);
if (SWAPW(NameRecord.platformID) == 1 &&
SWAPW(NameRecord.nameID) == 4)
{
fseek (fp, SWAPW (NameRecord.offset) +
SWAPW(NamingTable.stringOffset) +
SWAPL(Table.offset), SEEK_SET);
fread (&namebuf, 1, SWAPW(NameRecord.length), fp);
namebuf[SWAPW(NameRecord.length)] = '\0';
lstrcpy(lpszLongName,namebuf);
fseek (fp, curseek, SEEK_SET);
csOutName = lpszLongName;
}
}
break;
}
}
fclose (fp);
return csOutName;
}
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
|
|
|
|
|
great help , Thank you
|
|
|
|
|
Is there a way to hide a running app from task manager? Can I hide this app so that it will not be seen when alt-tab is pressed?
Thanks!
----------------------
Senior Software Developer
William Dicks
http://www.nanoteq.com/
|
|
|
|
|
This seems like a "try google" type question, but I honestly have and can't find a tutorial anywhere.. so:
Where can I learn to create my own control for an MFC app using visual c++?
Cheers,
Rewbs
|
|
|
|
|
See the beginner's section here, should be everything you need:
http://www.codeproject.com/miscctrl/
James.
|
|
|
|
|
It doesn't work....
I make a ADO connection with my database in my app:
myapp.cpp:<small><br />
void CMyApp::CMyApp()<br />
{<br />
<br />
try <br />
{<br />
HRESULT hr = m_pConn.CreateInstance (__uuidof (Connection));<br />
<br />
if (FAILED (hr))<br />
{<br />
AfxMessageBox ("Can't create intance of Connection");<br />
}<br />
<br />
if (FAILED (m_pConn->Open (_bstr_t ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = Database.mdb"),<br />
_bstr_t (""), _bstr_t (""), adModeUnknown)))<br />
{<br />
AfxMessageBox ("Can't open datasource");<br />
}<br />
}<br />
catch ( _com_error &e )<br />
{<br />
_bstr_t bstrSource (e.Source());<br />
_bstr_t bstrDescription (e.Description());<br />
TRACE ( "Exception thrown for classes generated by #import" );<br />
TRACE ( "\tCode = %08lx\n", e.Error ());<br />
TRACE ( "\tCode meaning = %s\n", e.ErrorMessage ());<br />
TRACE ( "\tSource = %s\n", (LPCTSTR) bstrSource);<br />
TRACE ( "\tDescription = %s\n", (LPCTSTR) bstrDescription);<br />
<br />
AfxMessageBox ((LPCTSTR) bstrDescription);<br />
}<br />
catch (...)<br />
{<br />
TRACE ( "*** Unhandled Exception ***" );<br />
}<br />
<br />
}<br />
</small>
Header file:
myapp.h:<small><br />
CDatabaseClass AppDatabase;<br />
_ConnectionPtr m_pConn;<br />
</small><br />
Then i send the pointer(m_pConn) to a new made class and check the database:
myapp.cpp:<small><br />
void CMyApp::CheckLogin()<br />
{<br />
AppDatabase.m_pConn = m_pConn;<br />
if (AppDatabase.CheckLogin(Name, Pass))<br />
{<br />
AfxMessageBox("login correct");<br />
}<br />
}<br />
</small>
Check Function(here it goes wrong):
DatabaseClass.cpp:<small><br />
bool CDatabaseClass::CheckLogin(CString Naam, CString Pass)<br />
{<br />
bool login;<br />
try <br />
{<br />
CString tmpNaam, tmpPass;<br />
<br />
Naam.Replace("'", " ");<br />
Pass.Replace("'", " ");<br />
<br />
login = FALSE;<br />
<br />
_CommandPtr pCommand;<br />
pCommand.CreateInstance (__uuidof (Command));<br />
pCommand->ActiveConnection = m_pConn;<br />
pCommand->CommandText = "Select * From Gebruikers;";<br />
<br />
_RecordsetPtr pRecordset;<br />
pRecordset.CreateInstance (__uuidof (Recordset));<br />
pRecordset->CursorLocation = adUseClient;<br />
pRecordset->Open ((IDispatch *) pCommand, vtMissing, adOpenForwardOnly, adLockReadOnly, adCmdUnknown);
<br />
while (!pRecordset->GetadoEOF())<br />
{<br />
tmpNaam = (char *) (_bstr_t) pRecordset->Fields->GetItem("Naam")->Value;<br />
tmpPass = (char *) (_bstr_t) pRecordset->Fields->GetItem("Pass")->Value;<br />
<br />
if {(tmpNaam == Naam) && (tmpPass == Pass)) { login = TRUE; }<br />
<br />
pRecordset->MoveNext();<br />
}<br />
<br />
pRecordset->Close ();<br />
} <br />
catch( _com_error &e )<br />
{<br />
_bstr_t bstrSource(e.Source());<br />
_bstr_t bstrDescription(e.Description());<br />
TRACE( "Exception thrown for classes generated by #import" );<br />
TRACE( "\tCode = %08lx\n", e.Error());<br />
TRACE( "\tCode meaning = %s\n", e.ErrorMessage());<br />
TRACE( "\tSource = %s\n", (LPCTSTR) bstrSource);<br />
TRACE( "\tDescription = %s\n", (LPCTSTR) bstrDescription);<br />
}<br />
catch (...)<br />
{<br />
TRACE ( "*** Unhandled Exception ***" );<br />
}<br />
<br />
return login;<br />
}<br />
</small>
Well, this doesn't work, the while loop doesn't even get reached. I don't know what i do wrong. Is it possible to send the database pointer around like this?
[]D [] []D []
|
|
|
|
|
Hi,
I have a window CMyWnd implemented by ATL
(actually, it's an ActiveX full control, but that shouldn't matter...)
This window uses a 3rd party library to create a child window. All I have is the window handle of the child window.
to prefilter the messages that are sent to the child, I want to:
a) replace the WNDPROC of the child with a global function of my own
b) use a global map<hwnd-of-child, cmywnd="" *="">, where the CMyWnds register in OnCreate, and remove themselves in OnDestroy
c) in my own wndproc, using the map to call CMyWnd->FilterMessageFromChild(...)
d) the message decides whether it should be passed on to the original WNDPROC, or not
Question:
now, this (should) work like a charm, however, I see that most of what TL does is exactly the same: global WNDPROC, mapping to a CWindow-dereived class, and calling with an BOOL & bHandled parameter to decide if the message is passed on
Is it possible to reuse ATL's own infrastructure for that?
TIA
Peter
So many people long for eternity that don't know what to do on a rainy sunday afternoon. [sighist] | [Agile Programming] [doxygen] If you look for evil in me you will find it whether it's there or not.
|
|
|
|
|
Hi all,
I have a dockable CDialogBar in an MDI application, however once i have created the CDialogBar and declared it as dockable, how do I make it not dockable, ie cannot be moved around the screen. This is going to be a user setting option, therefore I need to be able to make the Dialog both docking enabled and docking disabled.
Any help would be highly appreciated
Thanks
Neo
|
|
|
|
|
Hello folks!
I'm getting completely nuts with this CWnd::SetFont function. I tried to change the font in my CListControl (m_list), but this sh** control doesn't care about this command!
What's wrong?
Here is my code:
CFontDialog dlg;<br />
dlg.DoModal();<br />
CString face(dlg.GetFaceName());<br />
<br />
CFont pFont;<br />
pFont.CreatePointFont(120,face);<br />
m_list.ResetContent();<br />
m_list.SetFont(&pFont);
Thanks for help!
Bye, Jan
|
|
|
|
|
seeing ur code..i guess the error is u are calling the dailog first to show then setting font..whereas u must do it like this..
CFont pFont;
pFont.CreatePointFont(120,face);
m_list.ResetContent();
m_list.SetFont(&pFont);
CFontDialog dlg;
dlg.DoModal();
CString face(dlg.GetFaceName());
although i could not make out what is this face for..(never mind..)
i hope this works now..
cheers
Himanshu
|
|
|
|
|
Nope, that won't work either, since m_list, if it's a dialog member, won't be a window before DoModal is called.
If you've a list control (m_list) member in the dialog, add a CFont member too, then your OnInitDialog stuff for the dialog does the usual OnInitDialog stuff, creates the font, then sets the font via m_list.SetFont before returning.
The usual problem is that your font object goes out of scope; if it's a member of the dialog then it won't.
"Dialog objects are further away than they appear"
Steve S
[This signature space available for rent]
|
|
|
|
|
OK, thank you for this hint!
The fact that the CFont pFont looses scope at the end of this OnButton() function was the fault. After declaring the CFont pFont as a private member variable of my dilog everythings ok!
|
|
|
|
|
confused:hi all,
i want my application to run when it is scheduled..else it just sits idle in task bar..i can do everything else than scheduling as windows task scheduler does..can anyone help..me completing my work..any help and pointers are thouroughly appreciated..
thanks in advance..
Himanshu
|
|
|
|
|
SetWaitableTimer() CreateWaitableTimer()
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
:(thanks ted..but that doesn't solve my problem..because if user will exit the process manually it will stop..and i don't want that..i want it to run in back..and do the job when it is scheduled to..even if user exits it from the system tray..can it be done..
thanks for help..
cheers
Himanshu
|
|
|
|
|
If you don't want to allow the user to stop it, write it as a service, or possibly make use of the 'AT' command for scheduling a task, but there again the user could stop this as well!
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Hi,
when using std::less for a type where it's not defined (complex<double> in this case) like this:
template <class FLOAT>
int Foo(FLOAT & a, FLOAT & b)
{
std::less _less;
if ( _less(a,b)) {
...
}
}
I get the error:
C:\Programme\DevStudio6\VC98\INCLUDE\functional(86) : error C2784: 'bool __cdecl std::operator <(const class std::multimap<_K,_Ty,_Pr,_A> &,const class std::multimap<_K,_Ty,_Pr,_A> &)' : could not deduce template argument for 'const class std::multimap<_K,_Ty,_Pr,_A> &' from 'const class std::complex<double>'
C:\Programme\DevStudio6\VC98\INCLUDE\functional(86) : while compiling class-template member function 'bool __thiscall std::less<class std::complex<double> >::operator ()(const class std::complex<double> &,const class std::complex<double> &)
const'
now I wonder - how comes multimap into the game??
|
|
|
|
|
Hi,
how can I call a template member function, where the template parameters can not be deduced from the parameter list?
I have the following:
class CFoo
{
template<class FLOAT, int OP>
void Bar(FLOAT & a, FLOAT & b)
{ ... }
}; the following doesn't work.:
CFoo foo;
float a, b;
foo.Bar<float, 1>(a,b);
Any ideas?
Peter
So many people long for eternity that don't know what to do on a rainy sunday afternoon. [sighist] | [Agile Programming] [doxygen] If you look for evil in me you will find it whether it's there or not.
|
|
|
|
|
I was stuck in the same problem for some time one week ago...
I'd posted a question here and a lot of answers came to me, the reason it's a compiler limitation...
the compiler need the function definition and it's declaration to be in the same file...
I know this is not the better thing to do and that's not very clean, but it's the only way to make it work...
hope this helps...
|
|
|
|
|
|
Thanks!
took a bit of juggling around with forward decls, but works like a charm...
So many people long for eternity that don't know what to do on a rainy sunday afternoon. [sighist] | [Agile Programming] [doxygen] If you look for evil in me you will find it whether it's there or not.
|
|
|
|
|
I'm just curious. There seems to be no float/double version of the _wtoi(wide-character string to an integer) function. Is there such a function and if not why?
And the living obscurely rejoice at the news of a death, in the knowledge that it's not us, that we are still in the game.
Andrew Greig
|
|
|
|
|
This function available in VC++ 7.0. I think Latest platform SDK will solve your problem.
|
|
|
|
|
Do you know what it is called? _ttof? _wtof?
And the living obscurely rejoice at the news of a death, in the knowledge that it's not us, that we are still in the game.
Andrew Greig
|
|
|
|
|
|