|
Try to use inline function.
Also, check the compiler options, eg. stack checking, optimizations...
Do you build the release or debug version?
The other way is to set on assembly listing in compiler options and compare different solutions of coding.
Indeed, calling a function brings some overhead into your code. You can verify this examining mixed source and assembly listing, if compiler allows this (VC6 does allow). Generally, optimization can be a big problem and there is no perfect and only solution.
|
|
|
|
|
Yes, I tried to use inline, that didn't help. The test was done in release mode.
|
|
|
|
|
If you can step through your code, you could pin-point the costy call with the use of the @clk pseudo-register.
In your watch window, add
<br />
@clk<br />
@clk=0<br />
When you step, the value for @clk will give you how long it took.
Hope this helps
|
|
|
|
|
|
You say your GetPixel() function. What are you doing in that function? The windows GetPixel() function is very slow to begin with, so if you are calling that one then it is no wonder your function is slow. That is why DIBSections were invented, so that one could access the pixels directly as you have done instead of relying on GetPixel(). Check out the Bitmaps section here on CP for some excellent DIBSection articles.
|
|
|
|
|
My GetPixel() function is the same as the code I posted. It just dereferences the pointer. On top of that it checks if the indices are within limits and if not it returns a 0.
I rewrote my gaussian blur algorithm to use the memory directly, without GetPixel() and now my results are 10 times faster.
BTW. Thanks for the @clk tip.
|
|
|
|
|
I want to capture sound what is coming on my speaker ... not through microphone .... just the way i capture screen shot and save to disk .... is there a way to record the sound which are being played in window ... like for instance, i am listening a sound and another application is recording ... to be exact and specific that application records every sound that is played which that application is running ...
Any idea or suggestion
Any sort of help is highly appreciated
Regards,
Ibraheem Khan
|
|
|
|
|
Hi,this has been bugging me along time now and I haven´t been able to solve it yet.
I want to be able to remove a close button from an application so i can move another band to the space that was previously taken up by the close button.
I have done this successfully with a commandbar using this code:
HWND hwndCB;
TBBUTTON tbbutton;<br />
<br />
for(int i=0;i<10;i++){<br />
SendMessage(hwndCB, TB_GETBUTTON, (WPARAM)i, (LPARAM)&tbbutton);<br />
if(tbbutton.idCommand==WM_CLOSE)<br />
break;<br />
}<br />
<br />
SendMessage(hwndCB,TB_DELETEBUTTON, (WPARAM)i, (LPARAM)0 );
But unfortunately this didn´t work with the rebar control, it only removed the close button, and did not freed any space that the close button took up.
You add a close button to a rebar control using addadornments:
CommandBands_AddAdornments (hwndCB, hInst, 0, NULL);
But how in the heck do you do if you wan´t to remove it then?
There are no RemoveAdornments function and no info on this issue....
If i had the code I would have to recreate the rebar and not add any addornments to get rid of the close button.
But as i said before I don´t have the code.....
Does anyone have any idea how to solve this?
Please help, I´m going crazy...
Thanks for helping me out, Dani
|
|
|
|
|
Dialogs and Windows seem to be handled very different in Win32. Is there a way to check if a HWND is a Dialog (using DWL_DLGPROC), or a Window (using GWL_WNDPROC) ?
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
I found this in one of my old libraries. Can't say that it's foolproof though as I don't remember using it much. (I made a function for each system class, but primarily only used AfxIsEdit, AfxIsComboBox)
BOOL AfxIsDialogBox(HWND hWnd)
{
return (AfxIsSystemClass(hWnd, _T("#32770")));
}
BOOL AfxIsSystemClass(HWND hWnd, LPCTSTR lpszSystemClassName)
{
ASSERT(::IsWindow(hWnd));
if (!::IsWindow(hWnd))
return FALSE;
ASSERT(AfxIsValidString(lpszSystemClassName));
if (!AfxIsValidString(lpszSystemClassName))
return FALSE;
TCHAR szClassName[100];
return (::GetClassName(hWnd, szClassName, 100) && _tcsicmp(szClassName, lpszSystemClassName) == 0);
}
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Jack Squirrel wrote:
return (AfxIsSystemClass(hWnd, _T("#32770")));
That may not always work, as you can superclass dialogs.
--
An eye for an eye will only make the world blind.
|
|
|
|
|
How?
(Couldn't find anything in thew Dialog Box API)
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
How to subclass, or how to detect subclassed dialogs? The answer to the first one is in the ATL library. I stumbled upon it one day as I was making my own dialog windows. The answer for the second question is: I don't know. Dialogs are tricky, that's for sure.
--
An eye for an eye will only make the world blind.
|
|
|
|
|
Jörgen Sigvardsson wrote:
That may not always work, as you can superclass dialogs.
I got an idea about using one of the dlg based functions on a non-dlg window and eventually found this system error:
ERROR_WINDOW_NOT_DIALOG - The window is not a valid dialog window
The problem is, the only dialog function I can find that returns the value is EndDialog.
if (!EndDialog(hWnd, 0))
{
if (GetLastError() == ERROR_WINDOW_NOT_DIALOG)
}
else
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
EndDialog is not the ideal function in most cases.
How about MapDialogRect(), or GetDlgItem()?
--
An eye for an eye will only make the world blind.
|
|
|
|
|
Tried GetDlgItem before, didn't work. MapDialogRect does work though.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
H@llo
I have a class with some memberfunctions and like to refer to these by unsing functionpointers.
all my tries ends up in errors
some sample here:
<br />
class myCom<br />
{<br />
public:<br />
int send(int,char*);<br />
int read(int,unsigned int,BYTE*);<br />
};<br />
<br />
class myCom;<br />
typedef int (*cdout)(int ,char* );<br />
typedef int (*cdread)(int ,unsigned int ,BYTE* );<br />
class action<br />
{<br />
myCom* mCom;<br />
...<br />
};<br />
<br />
...<br />
mCom = new myCom;<br />
...<br />
cdout test = mCom->send;
or<br />
cdout test;<br />
test = mCom->send;
...<br />
Anyone any idea??
THX
|
|
|
|
|
you have
typedef int (*cdout)(int ,char* ); and
int send(int,char*);
but send is a member function... its synopsis is not what you wrote. it gets an implicit parameter (this ). send() actually has 3 parameters.
if you want to use it, you must declare it as a static function.
but if it uses data members of its class, it won't see them anymore.
so you'll have to pass a new parameter explicitely to your send() function to allow it accessing the members. You'll also have to change the cdout declaration...
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hallo
OK - got it so far.
But at least i like to send this functionpointer to a created dll.
So ifsend() is static i have to change to much code.
Changeing the typedef restricts the needed parsing possibility
for my dll.
I'm sorry, but i'm not very good in c programming. Is there any other fast possibility to call a dll function that communicating with class member functions?
THX
|
|
|
|
|
just put send not a member function... (say it is global... or at least, from within a namespace of your own)
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
Hello brothers...
I tried my best but could not get solution to my problem. Please help me.
I can not understand why this error message is comming. I have changed my code but error is still there.
My code is as follows.
void CMyThreadDlg::OnOK()
{
if (m_check) // if check box is checked
{
AfxBeginThread(ThreadProc,NULL,THREAD_PRIORITY_NORMAL,0,0,NULL);
MessageBox("Thread Started");
}
CDialog::OnOK();
}
UINT ThreadProc( LPVOID Param )
{
ofstream fout;
fout.open("thread.txt");
for(int i=0;i<=100;i++)
{
fout <<i <<' ';
}
fout.close();
return 0;
}
Error message is,
<b>AfxBeginThread' : ambiguous call to overloaded function</b>
We Believe in Excellence
|
|
|
|
|
maybe ThreadProc is an identifier already existing...
you could either change its name, or use the :: scope operator...
(and please explain better you problems next time...)
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi,
I think you ar passing to many parametrs to AfxBginThread() (I don't have MSDN on this computer...).
Anyway try this :
void CMyThreadDlg::OnOK()
{
if (m_check)
{
AfxBeginThread(ThreadProc,NULL);
MessageBox("Thread Started");
}
CDialog::OnOK();
}
[EDIT]
I've checked and you are passing the right parameters,so you have 2 more options:
1. Declare your thread on top of your file:
UINT ThreadProc(LPVOID lpvoid);
and then use it.
2. You already have a function calld ThreadProc.
Try a different name to your thread.
Regards,
Eli
|
|
|
|
|