|
I do not see any problem. The variable vert is a pointer to an array of type vertices_structure. The [] (brackets) are just away to access the items in the array.
If you did something like this:
vertices_structure temp;
vertices_structure* pTemp = &temp;
int muh = pTemp[0].array_pos;
int muh = pTemp[1].array_pos;
Good luck!
INTP
|
|
|
|
|
how would i go about allowing a dll to call a function in my program? i have a hook setup in the dll in which i append a few items to the system menu of all applications, and based on some settings in my main application i would like to append different menu items.
should i pass a function pointer? or is there some easy magical way to do this? thanks.
jason
|
|
|
|
|
No magic. Pass an object or a function pointer or give the dll a window handle and have it send a message to the window or... anything else you can come up with that does not rely on magic.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
i like the message idea. thanks!
jason
|
|
|
|
|
Hi Group,
for a project[1] I am trying to find an OS independant way to measure the amount of cpu usage
and memory consumption of the program. It would be nice if I could do that in my C++ code, so I
can show the results at runtime or even plot a nice graph (I got wild dreams).
After some google'ing I found some (nice) examples[2] but they are all windows based. Does
universal code for this problem exist?
Of course I can make different classes (one for windows and another for *nix), I do something
similar to assign sockets. But then I also need code for *nix, without using bash-scripting of
course.
So I am looking for something OS independant, but examples for windows or *nix can help me out
for now as well.
Goodnight everyone and thanks in advance,
--wim
______
[1] I am trying to compare some differint multicast protocols, and yes, also cpu usage and
memory consumption is an important part of that
[2] if anybody wants them, I can always post links, just ask
|
|
|
|
|
Does universal code for this problem exist?
Highly unlikely. The best you could do is write generic code for the other parts of the application and write OS specifics in wrapper DLLs keeping a common interface for each wrapper you create.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
Yeah, I kind of gave up the search to "universal code" (I just like the sound of it (- . I guess I'll have to write separate implementations for each OS and use conditional compile statements in the source code.
Another major problem is that I haven't found interesting code concerning memory consumption. Until now, I only found ways to measure CPU-cycles and only for windows. Can anyone help me?
Many kind greetings and thanks in advance,
--wim deprez
|
|
|
|
|
I use embedded visual c++ to write a video cam software, so that the pocket PC show the screen of the cam. But my menubar does not work.(I tick the top up box) When I click the top up button in menubar, the menubar hangs. But the screen still can show the video.
void CGroup7Dlg::OnPreview()
{
unsigned char *pbuffer = (unsigned char *)malloc(m_PrvWidth * m_PrvHeight * 3);
unsigned char *rpbuffer = (unsigned char *)malloc(m_PrvWidth * m_PrvHeight * 3);
if ((PreviewFrame((unsigned char*) pbuffer)) == false)
AfxMessageBox(_T("Preview Frame Fail!"), MB_OK);
Rectify(pbuffer, rpbuffer); //<----- a
CBitmap bitmap;
bitmap.CreateBitmap(m_PrvWidth, m_PrvHeight, 1, 24, rpbuffer);
CVOImage image;
RECT pic_rect;
m_picture_window.GetWindowRect(&pic_rect);
HDC picDC = ::GetDC(m_picture_window.m_hWnd );
CString path_fname;
::WriteBitmapIntoJpegFile(TEXT("\\pic1.jpg"), 80, (HBITMAP)bitmap);
UpdateData(true);
path_fname ="\\My Documents\\pic1.jpg";
image.Load (picDC ,path_fname );
image.Draw (picDC ,2,13 );
free(pbuffer);
pbuffer = NULL;
free(rpbuffer); //<-------b
rpbuffer = NULL;
}
There will be out of memory if I comment out line b but menubar works. There will be no problem but the screen pixel is in wrong order of course. I don't know how to fix this bug. Please help...
|
|
|
|
|
There will be out of memory if I comment out line b but menubar works
There will be a memory leak if you did that.
Howabout to set your pbuffer and rbuffer as a member variable?
And why don't you use new/delete instead of malloc/free?
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Thank you so much, I have tried your method:
unsigned char *pbuffer = new unsigned char[m_PrvWidth * m_PrvHeight* 6];
unsigned char *rpbuffer = new unsigned char[m_PrvWidth * m_PrvHeight* 6];
.
.
.
delete[] pbuffer;
delete[] rpbuffer;
But, the same problem is still there. And the "out of memory" dialog pop up continuously..........help.........please
Do you have any idea?! >_<
|
|
|
|
|
It could be that there is a memory leak in your program.
Try CMemoryState to trace where is it.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Instance name from Thread Id?
Hi,
I'm using pdh to generate Performace data for a thread in my multithreaded program.
The counter should be like
"\\Thread(App/3)\\% Processor Time"
here App/3 is the name of the instance for the thread.
My question is:
I know the thread Id for my thread, how do I find the instance name of the thread from my program?
Please help
|
|
|
|
|
See the MSDN topic for SetThreadName.
Since you must set the thread's name, how could you not know it when the thread is running?
Otherwise, this is just some default name the system gave your thread, and I would encourage you to give it a meaningful name yourself, when it starts up.
|
|
|
|
|
I tried your suggestion, but that thread name is not shown in the perfmon Thread instance list. Seems like it is still showing as one of App/0, App/1 etc.
Please suggest any other method
|
|
|
|
|
sorry it is giving error for except.
I included windows.h, excpt.h..still
typedef struct tagTHREADNAME_INFO<br />
{<br />
DWORD dwType;
LPCSTR szName;
DWORD dwThreadID;
DWORD dwFlags;
} THREADNAME_INFO;<br />
<br />
void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName)<br />
{<br />
THREADNAME_INFO info;<br />
info.dwType = 0x1000;<br />
info.szName = szThreadName;<br />
info.dwThreadID = dwThreadID;<br />
info.dwFlags = 0;<br />
<br />
__try<br />
{<br />
RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(DWORD), (DWORD*)&info );<br />
}<br />
except(EXCEPTION_CONTINUE_EXECUTION)<br />
{<br />
}<br />
}
|
|
|
|
|
I used __except, compiled.
But still I cant see the name of the thread in the list of perfmon
|
|
|
|
|
I do not know any other mechanism.
Perhaps the PerfMon is just enumerating the threads somehow, and it just assigns each one a number based upon its order of being returned or indexed. It might not necessarily be using a thread 'name' so much as appending thread number after name of process.
Have you seen any other application with decorated thread names? Or are all processes using the same scheme?
I was not able to readily locate any further information relating performance monitor and threads.
|
|
|
|
|
For a windows program I am making I need to detect arrow key presses.
Now I have a switch statement:
switch(nChar)
{
case VK_DOWN:
// do stuff
break;
case VK_RIGHT
...
}
but I need to detect if multiple arrow keys are being pressed at once, how can I do this?
(my OnKeyDown handler no longer does anything when a key is pressed. I'm not sure but it might be it doesn't have the focus, though I actually have no idea. Any ideas on that?)
Any help is greatly appreciated.
Thanks.
|
|
|
|
|
|
I have taken a look at that, but this time I noticed I need to give my view the keyboard focus (how can I do this?).
Thanks.
Though I'm still not sure how to detect multiple arrow key presses at once, I tried getting the flags with "ah 12h, int 16h" but that only returns flags that hold shift,ctrl,insert,etc.
So how do I detect that two (or more) arrow keys are being pressed at once?
|
|
|
|
|
Take a look at the function GetKeyState(VK_DOWN) , should return the state of the key, pressed or not etc.
You will need to call it once for each key you want to check.
If you vote me down, my score will only get lower
|
|
|
|
|
I'm going crazy over TB_ADDSTRING. I can't get it to work properly.
For example, this will work:
TCHAR* pCaption = _T("I Hate TB_ADDSTRING");
iIndex = ::SendMessage(m_hWnd, TB_ADDSTRING, (WPARAM)0, (LPARAM)pCaption);
pCaption = _T("Did I mention that I Hate TB_ADDSTRING?");
iIndex = ::SendMessage(m_hWnd, TB_ADDSTRING, (WPARAM)0, (LPARAM)pCaption);
However, this will not:
TCHAR szRes[255];
LoadString( m_hResModule, IDS_SOMESTRING, szRes, sizeof( szRes ) );
iIndex = ::SendMessage(m_hWnd, TB_ADDSTRING, (WPARAM)0, (LPARAM)szRes);
LoadString( m_hResModule, IDS_SOMETHING, szRes, sizeof( szRes ) );
iIndex = ::SendMessage(m_hWnd, TB_ADDSTRING, (WPARAM)0, (LPARAM)szRes);
What is going on?!
|
|
|
|
|
Check the return value from LoadString()
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Hi,
LoadString return value is fine, it' the TB_ADDSTRING part that is confusing me!
|
|
|
|
|
From the docs:If hinst is set to NULL, idString points to a character array with one or more null-terminated strings. The last string in the array must be terminated with two null characters. Neither of your examples is right - you pass a single null-terminated string - but by sheer luck the first example is working because after your literals there happen to be two nulls.
In your second example, init your TCHAR array to all zeros before the LoadString() calls and it will work
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Actual sign at the laundromat I go to: "No tinting or dying."
|
|
|
|