|
YOu can't do it with #define. You should declare it as a const array, like this, using a CString or an STL string:
const CStirng Hash[] =
{
"data",
"data",
...
};
Or you could use char * in a similar way (I believe... no compiler with me at the moment so the syntax might not be 100% correct... ):
const char **hash =
{
"data",
"data",
"data",
...
};
Even a broken clock is right twice a day.
|
|
|
|
|
define it as:
<br />
char *Hash[10] = <br />
{"208803DD4D",<br />
"146DB1CB1C",<br />
"26D2199CFA",<br />
"7CAFF3D504",<br />
"6C40AB0E42",<br />
"1E1D7486BE",<br />
"A03E54D487",<br />
"7ACC08F3F7",<br />
"7ACC08F3F7",<br />
"6B0133E813",<br />
"114CFE0C12"<br />
};<br />
|
|
|
|
|
That won't work. Lose the *
Signature space for rent. Apply by email to....
|
|
|
|
|
|
How to convert float numbers to a CString class or a char type?
And how to convert a char type to a float number?
Thks in advance!
Appstmd
http://www.appstmd.com
|
|
|
|
|
|
|
Look up CString::Format
Jason Henderson start page articles "If you are going through hell, keep going." - Sir Winston Churchill
|
|
|
|
|
use std::ostringstream .
You use its << operator to shift the number in, and get the textual representation of it via its str() memberfunction.
|
|
|
|
|
anyone can kindly help me with this? thx a lot in advance.
i created a subclass from CListCtrl named uiCtrlListCtrl.
in the new class i implemented a message handler for OnLButtonDown, but i don't know how to get the Control List's Identifier inside the handler of this message.
the message handler is as below:
void caauiCtrlListCtrl::OnLButtonDown(UINT nFlags, CPoint point){
...
CWnd* pwndParent = GetParent();
pwndParent->SendMessage(UI_WM_LBTNDOWN, ?what should i put here for the list control's ID? );
...
}
|
|
|
|
|
I guess this should have to work:
pwndParent->SendMessage(UI_WM_LBTNDOWN, ::GetWindowLong(m_hWnd,GWL_ID));
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
it works! really appreciate your help!
i just found another means, but not so simple as this way.
i added one variable and then use it to store the control id from calling GetDlgCtrlID().
int nIdFrom;
nIdFrom = GetDlgCtrlID();
pwndParent->SendMessage(UI_WM_LBTNDOWN, (WPARAM)nIdFrom);
|
|
|
|
|
Hi Friends
I want the check the class name of the window being created with a given string. Or to write all class names to a file. I am using WH_CBT Hook..
But the following code is giving a memory cant read error. Any idea?
Regads.
Gaurika.
LRESULT CALLBACK FindToolbarProc(int nCode, WPARAM wParam, LPARAM lParam)
{
// watch window creation:
if (nCode == HCBT_CREATEWND)
{
CBT_CREATEWND* pcw = (CBT_CREATEWND*)lParam;
// watch for Notepad creation, set toolbar name
if (pcw->lpcs->lpszClass &&
0 != strstr(pcw->lpcs->lpszClass, "Notepad")) //
{
Beep(1000,100); // Just to Identify…..
}
}
return CallNextHookEx(g_hkCBT, nCode, wParam, lParam);
}
Gaurika Wijeratne. // www.gaurika.com
|
|
|
|
|
Can you use the typeID operator available with the RTTI?
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Not with this particular problem he can't...
He wants the MS windows window class string, not a window object class name.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I don't know exactly and i'm to lazy to make a Q and D app to test yer code, but i'll offer my suggestion.
LRESULT CALLBACK FindToolbarProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode == HCBT_CREATEWND)
{
CBT_CREATEWND* pcw = (CBT_CREATEWND*)lParam;
ASSERT(pcw);
if(strcmp(pcw->lpcs->lpszClass, "Notepad") == 0)
Beep(1000,100);
}
return CallNextHookEx(g_hkCBT, nCode, wParam, lParam);
}
Are you sure that pointer is valid...?
Also I dunno if this has anything to do with it...but...perhaps ReadProcessMemory() should be used...? I'm thinking because a windows window class is probably stored locally to the process that created it so trying to read it using c-style pointers might cause memory read errors...??? I have no idea other than that...
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hi,
I have a threads problem and here it is:
I am developing a program that will draw the graphic of a mathematical function but I want the draw to be done in other thread because for example if the multiplaier(the for is decreasing 'x' with 1/multiplaier) is too big, the program will draw the graphic slowly, and on every WM_PAINT message to my control the graphic has to be redrawn, and so if the user moves the window or whatever he doest to it, he will have to wait until the graphic is completly drawn, so I wanna make another thread to do this, but I have problem with the ThreadProc function:
I made a struct where all the parameters for the drawing are set:
<br />
typedef struct _DRAWERSUB {<br />
HDC dc;<br />
CRichEditCtrl *ctrlResults;<br />
char * strFormula;<br />
char * strX;<br />
float nMultip;<br />
int cx;<br />
int cy;<br />
double dPrecision;<br />
BOOL bPrecision;<br />
int nRootsFound;<br />
double nDivs;<br />
BOOL bCalc;<br />
} DRAWERSUB, *LPDRAWERSUB;<br />
this is the struct.
I initialize it in a function called by WM_PAINT as:
<br />
DRAWERSUB dwsub;<br />
dwsub.strFormula = (LPTSTR)(LPCTSTR)m_strFormula;<br />
dwsub.strX = (LPTSTR)(LPCTSTR)m_strX;<br />
dwsub.dc = dc->GetSafeHdc();<br />
dwsub.nDivs = m_nDivisions;<br />
dwsub.nMultip = m_nMultip;<br />
dwsub.cx = cx;dwsub.cy = cy;<br />
dwsub.bCalc = m_bCalc;<br />
dwsub.bPrecision = m_bPrecission;<br />
dwsub.dPrecision = precision;<br />
m_trGraphicDrawer = AfxBeginThread(GraphicDrawerSub,&dwsub);
and this is the code for the ThreadProc:
<br />
UINT CGraphicFunc::GraphicDrawerSub(LPVOID pParam)<br />
{<br />
LPDRAWERSUB dwsub = (LPDRAWERSUB)pParam;<br />
CString strFormula((LPCTSTR)(LPTSTR)dwsub->strFormula), strX((LPCTSTR)(LPTSTR)dwsub->strX);<br />
HDC hDC = dwsub->dc;<br />
double nDivs = dwsub->nDivs;<br />
float nMultip = dwsub->nMultip;<br />
int cx = dwsub->cx, cy = dwsub->cy;<br />
double dPrecision = dwsub->dPrecision;<br />
BOOL bPrecision = dwsub->bPrecision;<br />
BOOL bCalc = dwsub->bCalc;<br />
.....<br />
}<br />
but every time the ThreadProc is called, strFormula, strX and every value from it, has different value, sometimes the hDC is valid and sometimes it isn't...strFormula sometimes is "" and strX is something like this:
"U‹ìQƒeü"
What can I do for rapairing this problem???
I am not good at threads and I almost no experience with them ...
Thanks.
|
|
|
|
|
A quick hint, never use local variables in a thread proc. Just keep using dwsub-> even if this sounds not optimized.
Windows shared objects such like DCs can be locked using the WIN32 API.
Code sections can be locked for one thread only by using CriticalSection, Semaphore or Mutex. See MSDN.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
Thanks for the hint but it still dont works...the struct itself is some kind damaged because when I debug the application, in the thread proc, dwsub seems to be damaged ...
|
|
|
|
|
a possible solution:
in your example, the DRAWERSUB structure is defined on the stack...
So when you call the AfxBeginThread, the struct is valid. but before the thread starts, the method which called AfxbeginThread might end, and release the stack memory of the DRAWERSUB...
solution: either allocate it on the HEAP (using HeapAlloc) or make it a member variable of CGraphicFunc (but then you can only create one copy of the thread).
|
|
|
|
|
Hi world
I want to share a variable into a dll and all application using this dll handle the SAME variable (not a copy)..
How to do that?
Thanks in advance.
Hello World!!!
from Raphaël
|
|
|
|
|
use global atoms. Link on MSDN[^].
Btw, as long as you don't cross process boundaries, all dlls share the same address space, thus every variable pointer is available from anywhere.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
|
I'm getting back into programming after a long time off, and may post a few... silly questions. OK, here goes... I'm creating a network simulator, using (among other things), a number of derived classes that share a common base class. Most access to these classes is obtained through the use of a pointer to the base class, accessing the derived class functionality. All well and good. I'm having trouble, when I want to make a copy of one of the derived classes with a pointer to the base class. What I get is a copy of the base class only!
Should I be able to make a copy of a derived class if I'm using a pointer to it's base class? If so, do I need to set up either the base class or the derived class in such a way as to enable this copy function?
Thanks.
|
|
|
|
|
Hmmm
I couldn't reproduce your problem (I am using VC++.NET)
class B
{
public:
B()
{
a=100;
}
int a;
};
class D : public B
{
public:
D()
{
b=200;
}
int b;
};
int _tmain(void)
{
B* b1 = new D();
B* b2 = b1;
D* d = static_cast<D*>(b2);
printf("%d",d->b);
delete b1;
return 0;
}
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|