|
Hey
How come my post is anonymous?
Nish
Oh, I don't know why she's
leaving, or where she's gonna go
I guess she's got her reasons but I just don't wanna know
'Cos for 24 years I've been living next door to Alice
24 years just waitin' for a chance
To tell her how I feel and maybe get a second glance
Now I gotta get used to not living next door to Alice
|
|
|
|
|
What the hell is going on here Nish?All of us are anonymous???
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Mazdak wrote:
What the hell is going on here Nish?
Dunno. But stuff is sure goin on...
Mazdak wrote:
All of us are anonymous???
Yeah
Nish
Oh, I don't know why she's
leaving, or where she's gonna go
I guess she's got her reasons but I just don't wanna know
'Cos for 24 years I've been living next door to Alice
24 years just waitin' for a chance
To tell her how I feel and maybe get a second glance
Now I gotta get used to not living next door to Alice
|
|
|
|
|
I have only one icon resource in my project and it has two devices a 32x32 and 16x16. The icon in the upper left corner of my program is a shrunk down version of the 32x32 device. I would like it to use the 16x16 device instead. I dunno if this is possible but if anyone knows how please let me know.
Thank You
Susan
|
|
|
|
|
|
Mike,
Nicely done, I have wondered about this myself. This line in the faq didn't work...
HICON hSmallIcon = ::LoadImage ( AfxGetResourceInstance(), MAKEINTRESOURCE(IDI_NEW_ICON), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR );
I had to change it to...
HICON hSmallIcon = (HICON) ::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
I had to add the cast and change AfxGetResourceInstance() to AfxGetResourceHandle() I dunno if this is a version mismatch or something but this worked for me.
Thanks for the info
-Jack
|
|
|
|
|
oops, you're right on the function name. I mixed up the CWinApp and CComModule method names. (There is a CComModule::GetResourceInstance() .)
--Mike--
Rollin' in my 5.0
With the rag-top down so my hair can blow.
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
Hi,
I have an application where when I click a button on the tool bar, a dialog box opens. Then when i click a button on the dialog box another dialog box opens. However, when the 2nd dialog box is open then i can't click anything on the first one without closing the second one. How can I modify the message handler on the code of my first dialog so i can click on other stuff on it while the second box is open??
Thanks,
|
|
|
|
|
Currently your second dialog is a modal dialog, you will need to change it to a modeless dialog.
A modal dialog retains the focus until you explicity close it. If you are using the windows SDK then you call one of the variations of DialogBox in order to create this type of dialog. If you are using MFC then you call DoModal . When you want this type of dialog to go away you should call EndDialog .
A Modeless dialog does not require closing before switching to another window. If you are using the SDK, then you will call one of the variations of CreateDialog and then follow that with a call to ShowWindow to make it visible. The MFC way is similar in the fact that you will want to create the dialog window, probably the same way that you created the Modal dialog, however you will use the ShowWindow to make the dialog visible. When you want this type of diaog to go away, you can either call ShowWindow to hide it, or when you are done with it you can call DestroyWindow .
|
|
|
|
|
|
Read my article on modeless dialogs :-
http://www.codeproject.com/useritems/gettingmodeless.asp
Nish
Oh, I don't know why she's
leaving, or where she's gonna go
I guess she's got her reasons but I just don't wanna know
'Cos for 24 years I've been living next door to Alice
24 years just waitin' for a chance
To tell her how I feel and maybe get a second glance
Now I gotta get used to not living next door to Alice
|
|
|
|
|
Search for something about Modal (on showing the dialog) ! The dialog must not be MODAL !
icounter
|
|
|
|
|
Hi,
I'm doing multithread in my program. Due to some reasons, the thread needs to be suspended, and wait for some return signals to go on. However, it is possible that there is no return signal. I would like to add a time-out feature, so that the thread can resume after waiting for a period of time and doesn't have to wait indefinitely. (let say 5000ms).
Does anyone know how to do it?
Can I use QueryPerformanceCounter()........and how to use it?
Thanks
|
|
|
|
|
You can use this function:
DWORD WaitForSingleObject(
HANDLE hHandle,
DWORD dwMilliseconds
);
Set the time-out interval, and the handle that you use may be for the certain event that you are waiting for, here is a list of objects that this function will wait for:
- Change notification
- Console input
- Event
- Job
- Mutex
- Process
- Semaphore
- Thread
- Waitable timer
Look at msdn.micorsoft.com for more details on this function.
|
|
|
|
|
kilowatt wrote:
You can use this function:
DWORD WaitForSingleObject( HANDLE hHandle, // handle to object DWORD dwMilliseconds // time-out interval);
Where should this WaitForSingleObject() put? Should I put it in the thread function ?? Or......
More clear on my question:
My thread function needs to wait (suspend) a boolean value (T/F) from another function in order to go on. If my thread has been waiting too long, I want to resume this thread.
Thank you so much!!!!!!
|
|
|
|
|
kilowatt wrote:
You can use this function:
DWORD WaitForSingleObject( HANDLE hHandle, // handle to object DWORD dwMilliseconds // time-out interval);
Where should this WaitForSingleObject() put? Should I put it in the thread function ?? Or......
More clear on my question:
My thread function needs to wait (suspend) a boolean value (T/F) from another function in order to go on. If my thread has been waiting too long, I want to resume this thread.
Thank you so much!!!!!!
|
|
|
|
|
In the thread that should wait you use WaitForSingleObject. Instead of setting a boolean, you can set an event.
In other words...
In you main thread.
1. ::CreateEvent (...)
2. Start thread
3. Started thread waits on the event with a timeout using ::WaitForSingleObject
4. Main thread sets the event (::SetEvent) when the created thread should wake up.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
You will have to have two threads in order to do this. There are many ways of doing this. I will give you a simple example of how to do this in the SDK. If you are using MFC then there are objects that you can use to make it easier.
1) Create your worker thread proc, this will be the function that returns true or false, that your main thread waits on. If there are more than one input parameters to your worker thread function
then you will need to create a struct to hold these values. Here is an example, say your current
function looks like this:
BOOL function(int x, int y, float power);
Create a structure like this:
typedef struct FUNCTION_PARAMS
{
int x;
int y;
float power;
}; FUNCTION_PARAMS;
The address of this structure will be passed into the lpParameter of the WorkerThreadProc in order to get the initial parameters of the function.
DWORD WINAPI WorkerThreadProc(LPVOID lpParameter)
{
if (!lpParameter)
{
return FALSE;
}
FUNCTION_PARAMS *fp = (FUNCTION_PARAMS*)lpParameter;
float z = fp.x + f.y * fp.power;
...
return TRUE;
}
2) This is the thread that calls a function in thread two. Here are the actions that this thread should take:
FUNCTION_PARAMS fp;
fp.x = 1;
fp.y = 2;
fp.power = 100.0;
HANDLE hWorkerThread;
DWORD dwThreadID;
hWorkerThread = ::CreateThread(NULL, 0, WorkerThreadProc, &fp, &dwThreadID);
::ResetEvent(hThread);
DWORD dwState;
dwState = ::WaitForSingleObject(hWorkerThread, 5000);
if (WAIT_OBJECT_0 == dwState)
{
DWORD dwExitCode;
GetExitCodeThread(hWorkerThread, &dwExitCode);
if (TRUE == dwExitCode)
{
...
}
else
{
...
}
}
else
if (WAIT_TIMEOUT == dwState)
{
...
}
|
|
|
|
|
// OnInitialUpdate()
m_pSet = &GetDocument()->m_TestSet;
m_pSet->OpenAll();
// Save Button
CString mValue;
GetDlgItemText(IDC_EDIT_FIRST, mValue);
strcpy(m_pSet->m_First,mValue);
m_pSet->SetData();
m_pSet->Update();
The problem is that the new value for m_pSet->m_First does not save to the SQL Server 7.0 Database. When I trace, I can see the new value in the m_pSet->m_First.
Thanks
Peace in Christ
Marco Napoli
|
|
|
|
|
If anyone out there is feeling particularly adventuresome and has VC7 I could use some help. I have a C++ framework that I have been working on in VC 6 called the Visual Component Framework. However I have heard from some people who have downloaded it that it doesn't compile under VC7. I don't have the cash to get VC7 and I was wondering if there might be someone here who might be willing to give it a go ? The framework is free and can be found at http://sourceforge.net/projects/vcf
If you want to help out on this and have questions feel free to contact me.
Thanks
|
|
|
|
|
Hi,
I have an application which when run, starts with a menu, IDR_menu1. When I open a dialog box from the menu how can I change the menu from IDR_menu1 to say IDR_menu 2 which contains options for the dialog box. E.g (the original menu has File,Edit,View,Options,Test,Window and help and the new menu I want to replace it with has only File,Options,Window and Help)
Thanks in advance
|
|
|
|
|
Use LoadMenu to load your menu from the resource file, you will receive an HMENU from this function. Then you can call SetMenu(hWnd, hMenu) and this will set the new menu.
Then you may have to call DrawMenuBar in order to make sure that the menubar gets refreshed.
|
|
|
|
|
Hi,
I need a timer to count how long the program has been waiting:
e.g.
if (x=10)
{
pause indefinitely //i want the function pause for 1000ms......
if (timer = 1000ms) //function pause for 1000 ms already
continue to do stuff here....
}
How can i implement this timer??? Any example!????
Thanks!!!!
|
|
|
|
|
use QueryPerformanceCounter.
here is an example.
LARGE_INTEGER liFrequency;
LARGE_INTEGER liStart;
LARGE_INTEGER liEnd;
if (FALSE == QueryPerformanceFrequency (&liFrequency))
{
MessageBox("Your computer will not support this test. It does not contain a high resolution timer.", "Error", MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}
QueryPerformanceCounter(&liStart)
...
QueryPerformanceCounter(&liEnd)
LARGE_INTEGER liDiff;
double dTime;
liDiff.LowPart = liEnd.LowPart - liStart.LowPart;
liDiff.HighPart = liEnd.HighPart - liStart.HighPart;
dTime = (double)liDiff.LowPart / (double)liFrequency.LowPart;
I cannot remember what units dTime is in at this point, but if you test it in your debugger you should be able to figure it out. Then use dTime to test if it has been the second that you are looking for.
|
|
|
|
|
Thanks..........;P
|
|
|
|