|
Best approach - don't have static global variables. If you must, then set them up in your stdafx.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
You declared it in a header didn't you? I've seen this problem here a few times and the solution is the following: don't declare variables in header files!
Tou immediatly think: how do I use global variables? Without the static keyword, the compiler complains of having multiple defined symbols!
The solution to this problem is not to add the static keyword, but to plave the variable in a translation unit (*.cpp file). In the header you declare the variable as extern :
Foo g_SomeGlobalFoo;
extern Foo g_SomeGlabalFoo;
This should solve your problem.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Thank you very much, it worked.
|
|
|
|
|
You're welcome
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hi,
I want to create xp-style menu in win32.How it is possible & i am not able to put the strip(vertical).
|
|
|
|
|
Take a look at this[^] CodeProject sponsor.
|
|
|
|
|
I can't seem to get anything but ERROR_INVALID_ADDRESS when I want to allocate memory at a specific address.
I use this Win32 API function:
LPVOID VirtualAlloc(<br />
LPVOID lpAddress,<br />
SIZE_T dwSize,<br />
DWORD flAllocationType,<br />
DWORD flProtect<br />
);
I have used VirtualQueryEx to verify that the memory region is in the MEM_FREE state prior to attempting to VirtualAlloc memory from a MEM_FREE region.
I also set the argument flAllocationType to MEM_RESERVE and flProtect to PAGE_NOACCESS.
The minute I put NULL in for lpAddress it works fine.
I have tried rounding the address up to the next SYSTEM_INFO.dwPageSize and also tried rounding it up to the next SYSTEM_INFO.dwAllocationGranularity and appropriately adjusting (decreasing) the MEMORY_BASIC_INFORMATION.RegionSize which is used for the dwSize parameter.
Does anyone know what is the problem
|
|
|
|
|
1. Make sure that the address you want to allocate doesn't already exist or spand onto another address that does!
2. Make sure the address is 4k aligned. This means that you should allocate a number that is:
0xnnnnn000
So, 0x00003000 for example. If you display the address in HEX, the last 3 hex digits need to be 0 to be on a 4k boundary.
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
MEM_RESERVE -
1. lpAddress must be aligned with a 64K boundary (SYSTEM_INFO.dwAllocationGranularity)
2. dwBlockSize must be multiple of 64K (SYSTEM_INFO.dwAllocationGranularity)
3. Entire memory region must be free (I was already checking that)
MEM_COMMIT - within an already MEM_RESERVE region -
1. lpAddress must be aligned on the SYSTEM_IONFO.dwPageSize boundary
2. VirtualAlloc will internally adjust for dwBlockSize to be a multiple of SYSTEM_IONFO.dwPageSize, but VirtuAlloc will fail if lpAddress + dwBlockSize goes beyond end of MEM_RESERVE.
Carve another notch in the Totem dedicated to obtuse MSDN documentation
|
|
|
|
|
All the documentation on thread local storage is about using it in a DLL. I want to use it in a static library. Are there any issues?
|
|
|
|
|
DWORD g_dwThreadIndex = 0;
TCHAR *g_szFixedBuf = 0;
TCHAR *function()
{
if (g_dwThreadIndex == 0) {
g_dwThreadIndex = TlsAlloc();
}
if (g_szFixedBuf == 0) {
g_szFixedBuf = new TCHAR[1024];
}
// Do some thread specific work and put it in g_szFixedBuf
return g_szFixedBuf;
}
There are obviously two problems:
g_szFixedBuf is initialized once per process and not per thread. I can use a an array of pointers, one for each thread. But since the number of threads is unknown, not sure how long the array should be. The second problem is freeing the memory.
Any ideas how this can be addressed?
|
|
|
|
|
Why not make a Thread class where you put the Tls functionality. And if all your threads is started from that class you shouldnt have any problem destroying the Tls when the Thread object is destroyed. Never do global stuff... it really hurts the design.
Magnus
|
|
|
|
|
Hi all:
I have a program using a listctrl to display information from database which can sort the data by left click the headcontrol and then an image represent the sort state will be displayed. Everything works fine except running in Windows XP style. When I drag the column head with sort state image on it, the drag image become a whole black thing with nothing on it instead of the normal drag image with some transparency. This happens only for columns which have the sort state image on.
I use the following steps to set the sort image on the headcontrol:
<br />
CBitmap *pTempBmp = NULL;<br />
if( bAsc )<br />
pTempBmp = &m_bmpArrowUp;
else<br />
pTempBmp = &m_bmpArrowDown;
<br />
HD_ITEM Item; <br />
Item.mask = HDI_FORMAT;<br />
GetItem( nCol, &Item );<br />
Item.mask = HDI_BITMAP | HDI_FORMAT; <br />
Item.fmt |= HDF_BITMAP;<br />
Item.hbm = (HBITMAP)pTempBmp->GetSafeHandle();<br />
SetItem( nCol, &Item );<br />
So can anybody help me to solve this tiny problem?
Lisoft
|
|
|
|
|
i'm trying to remove an application from taskbar
<br />
#define mFunc(x) int __stdcall x(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)<br />
mFunc(Remove)<br />
{<br />
Attach(mWnd);<br />
RemoveTaskbarButton();<br />
hOwner = CreateWindow("STATIC","",WS_OVERLAPPEDWINDOW,0,0,0,0,0,0,0,0);<br />
<br />
ShowWindow(mWnd,SW_HIDE);<br />
<br />
SetParent(mWnd,hOwner);<br />
ShowWindow(mWnd,SW_SHOW);<br />
<br />
return 0;<br />
}<br />
and this don't work either
<br />
<br />
mFunc(IsTaskbarAutoHideOn)<br />
{<br />
APPBARDATA ABData;<br />
ABData.cbSize = sizeof(ABData);<br />
SHAppBarMessage(ABM_GETSTATE, &ABData);<br />
wsprintf(data,"%d");<br />
return 3;<br />
}<br />
any idea's why? or what i'm missing. still kind of new.. so can u guys show me what i'm missing?
"Don't fight with idiots, first they pull you down to their level, then they smash you with their experience"
|
|
|
|
|
I would have guessed that the property would be a VARIANT, ( or _variant_t, which is a wrapper ), not a number or string.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Ok i'm using this code to return a date, but the problem is I need the date of the day before this. How could I subtract a day from the date? And what if it's the first of the month, the day before that would be the previous month? Any suggestions?
char GTime[80];
time_t now;
now = time(NULL);
strftime(GTime,sizeof GTime,"%m %d %y\n",localtime(&now));
cout<
|
|
|
|
|
|
How about:
time_t now = time(NULL);
time_t yesterday = now - 86400;
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
COleDateTime odtNow = COleDateTime::GetCurrentTime();
COleDateTimeSpan dtSpan(1,0,0,0);
odtNow -= dtSpan;
Use MFC - it helps.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
hi
i m new to the field of activex and i want to know that are activeX (internet activex) made in the vc or vb are capable of self registering. or had to something extra to
register them. particularly the (internet activex) controll. if not that what functions will be used to register them.
i had made the (internet activex) that play the movie on the page i want to know that when user will visit my page then ocx will be selfdownloaded
and selfrejisted to that client pc. or what will happen.
ddd
|
|
|
|
|
When you compile an activex code in VC or VB environment, it self-registers them. For manually registering an ActiveX, you can use regsvr32 command on the command prompt.
When a user opens a web page which has an activeX, it self-registers it if user allows to get it installed on his machine.
Here[^]is a simpel tutorial on ActiveX controls in VC.
Einstein: "Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."
My Articles
|
|
|
|
|
hi
i had tried the issue of self rejisteration on my pc. i had installed the
iis and placed the web page containing the activex control. when i tried to run that web page the myactive x controll was not self rejistered. i had made ocx in one computer and check that thing on another machine to know whether self rejisteration occur or not but it dit not occured tell me what was wrong.
ddd
|
|
|
|
|
Did it ask you with a dialog to install the control or not? If it did, you should click yes to let it install itself.
Otherwise, there might be a problem with your internet explorer's security settings. Check the security level for Local Intranet and if it is high, lower it.
Einstein: "Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."
My Articles
|
|
|
|
|
no it did not show any dialog. it open the web page with empty i had also tried to lower the sccurity setting but it did not work too.
Be FaithFull To Your Work.
|
|
|
|
|
but no it did not show any dialog. i had also tried to lower the internet setting and run that but it did not work2.
when i debug through vc its environamnet register it and work fine. through the web page it does not work.
Be FaithFull To Your Work.
|
|
|
|