|
Try this code. You must have the hwnd of the process you're checking. The easiest way to get that is to call CreateProcess to spawn the app.
BOOL AppIsFrozen(HWND hWnd)
{
BOOL bFrozen = FALSE;
DWORD dwResult;
LRESULT nResult = ::SendMessageTimeout(hWnd, WM_NULL, 0, 0,
SMTO_ABORTIFHUNG | SMTO_BLOCK,
5000,
&dwResult);
if (nResult == 0)
{
if (dwResult == 0)
{
bFrozen = TRUE;
}
}
return bFrozen;
}
|
|
|
|
|
I M TRYING TO FIND THE CURRENT STAUS OF ANY APPLICATION/PROCESS LIKE MENTIONED IN TASK MANAGER.
|
|
|
|
|
Use EnumProcess () or use ToolHelp 32 functions
for more information see article Q175030
Kindest regards
Alfadhly
<marquee>
It is Illogical to define an inventor by his invention
|
|
|
|
|
I searched the whole MSDN, but I did't find the solution.
I need C++ functions which do the same
as the VB functions:
Trim
RTrim
LTrim
Hex
thanks in advance
|
|
|
|
|
CString::TrimLeft, and CString::TrimRight.
If you're not using MFC, you can always walk through the array, then use strcpy to make a copy of the bit that does not have leading or trailing spaces.
Assuming Hex allows you to specify a number in hex, its 0x, as in 0xFF = 255.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Hi
Can I use the SetStdHandle(...) function to redirect standard output stream (std::cout) to a windows socket opened by the function socket(...) ?
Thanx.
Ernst
|
|
|
|
|
Hello, i need somoene to help me.
I have created two dialog boxes, in the first one i have inserted a list ctrl in style report where i put some items with checkboxes associated. I want that when i click in an item that the item selected goes into the second dialog box with always a list ctrl.
i hope that i've explained clearly my problems, tks
|
|
|
|
|
Assuming one dialog is the parent of another, use GetParent() to get a pointer to it, and then put a function in the second dialog that inserts the item as you would like, and gets sent the string to insert.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I'm sorry but i'm just a beginner and i don't understand everything.to get the pointer to the parent dialog must i do like that :
m_panier.GetParent();
But if it i did is right how can i now put a fonction in the second dialog that gets the item, and gets sent the string to insert
Here a piece of my code which allows to display the index item selected (in the first dialog) in another Edit box (in the second dialog)
void CDThin::OnItemchangedListthin(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
CString strText;
CListedeprixApp* h_myApp = (CListedeprixApp *)AfxGetApp();
strText.Format(TEXT("Item index: %d\r\n "), pNMListView->iItem);
UpdateData();
m_Log3+=strText;
h_myApp->ListeDePrix() += strText;
UpdateData(FALSE);
*pResult = 0;
}
BOOL CDPanier::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CListedeprixApp* h_myApp = (CListedeprixApp *)AfxGetApp();
m_panier = h_myApp->ListeDePrix();
}
|
|
|
|
|
in my dialog,i added a toolbar on it,and one button(ID_MYBUTTON) with code:
CMyDilog::OnMyButton()
{
m_bFlag=!m_bFlag;
}
CMyDialog::OnUpdateMyButton(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck(m_bFlag);
}
but why can't the button's state be changed between pressed_state and unpressed_state?
Thanks in advance.
|
|
|
|
|
I don't recall how this works, but it's in PRetranslateMEssage. If you download my article "GDI+ Brushes and Matricies", I know for sure I had to impliment the fix you want there. The problem is that your OnUpdate function is not actually called.
I've just checked the code, and I put this in pretranslatemessage, before the call to PTM:
UpdateDialogControls( this, TRUE );
and this function as well:
LRESULT CGDIPlusBrushesDlg::OnKickIdle(WPARAM, LPARAM)
{
CMenu* pMainMenu = GetMenu();
CCmdUI cmdUI;
for (UINT n = 0; n < pMainMenu->GetMenuItemCount(); ++n)
{
CMenu* pSubMenu = pMainMenu->GetSubMenu(n);
cmdUI.m_nIndexMax = pSubMenu->GetMenuItemCount();
for (UINT i = 0; i < cmdUI.m_nIndexMax;++i)
{
cmdUI.m_nIndex = i;
cmdUI.m_nID = pSubMenu->GetMenuItemID(i);
cmdUI.m_pMenu = pSubMenu;
cmdUI.DoUpdate(this, FALSE);
}
}
return TRUE;
}
This means you need to put
ON_MESSAGE(WM_KICKIDLE, OnKickIdle)
in the messagemap of your CPP file ( it's near the top ), and
afx_msg LRESULT OnKickIdle(WPARAM, LPARAM);
with the rest of the generated message map funtions in the header file. I think that's all, if not, I'll have another look. So you don't need to download my article after all. Don't feel that not downloading it means you can't give me a five when voting starts for the .Net competition though
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
thank you for the people who replied to my question but i will state again my problem together with my code
"I have this Date and Time display in my window. Im using the Ontimer() / SetTimer() routine to update it...
but the problem is the "second" display's interval is not consistent.
It is not actually noticeable but when you compare it with the computers clock you can see it
ticking ahead sometimes. what can i do to solve this? "
here is how my program looks like
LONG xxxxxx::OnPageChange(UINT lPageNo, LONG lValue)
{
.
.
//Timer
SetTimer(1, 400, NULL);
.
.
}
void xxxxxx::OnTimer(UINT nIDEvent)
{
TimeDisplay();
CWnd::OnTimer(nIDEvent);
}
void xxxxxx::TimeDisplay()
{
SYSTEMTIME osTime;
GetLocalTime(&osTime);
//YEAR
.
.
//MONTH
.
.
//DAY
//HOUR
//MINUTE
//SECOND
if(oldtime[5] != osTime.wSecond){
oldtime[5] = osTime.wSecond;
//Display second here//
}
}
i tried making a new thread and call TimeDisplay().I created a while loop inside the TimeDisplay to repeat the process of displaying the clock until the thread ends. Thats the only i know to update the clock(since i cant use the WM_TIMER here or i can?) i just dont know how. The bad thing is that the CPU resources being used reached 100%.
whats the problem with my program? or what can be done to fix this? thanks to everyone who replied and will reply to this question. sorry for taking your time... i really appreciate your help....
Rachel
|
|
|
|
|
You don't need to create any threads just for displaying time. Just handle WM_TIMER message, read system time and display it as string.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
thats basically what im doing but my time display is sometimes not synchronous with the clock display of the computer.
|
|
|
|
|
What's the difference (in seconds) between the time you're displaying and clock and the one displayed in the system tray?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Just use Sleep(1000); in your thread
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
How can i get the total time when a decoder decode one frame?(decode to memory)
|
|
|
|
|
How can i get the total time when a decoder decode one frame?(decode to memory)
|
|
|
|
|
Problem seems simple, hours later and no documentation, I see I am licked. I am doing an exercise with a Win32 Console app, and I am attempting to write 2 overload functions to pass 2 similiar class objects to the function and recieve different results based on what I am passing. The parameters of the exercise are quite clear and as I have written thus far. Certainly there are better ways to code the end result, but I am not in control of the requirements. I am passing 2 char class objects and trying to get it to do 2 different things. What I can figure out is how to beat ambiguity. What do I have to pass it in order make this work. Any help for the idiot league of programming would be appreciateed.
My code so far, notes attached Using Visual C++ compiler
#ifndef _CLASSCAT121212121212112_ // 2 classes declared a cat and a dog
#define _CLASSCAT121212121212112_
class CCat
{
public:
char* catname;
};
#endif
#ifndef _CLASSDOG5456454654656546_
#define _CLASSDOG5456454654656546_
class CDog
{
public:
char* dogname;
};
#endif
#include <iostream.h>
#include "Cat.h"
#include "Dog.h"
void speak(char* n);
void speak(char* &n);
void main()
{
CCat cat1;
CDog dog1;
cat1.catname = "Felix";
dog1.dogname = "Fido";
speak("Felix");
speak(); <--- // how do I pass the dog argument to the function? How do I differentiate the two
}
void speak(char* n)
{
cout << n << " says meow " << endl;
}
void speak() // must make the dog go woof, but how do I pass it a different argument?
// how do I overload to beat ambiguity
{
cout << d << " says woof " << endl;
}
Much Thanks, Jason K. Dove
|
|
|
|
|
Just a few thoughts:
void speak(char* n);
void speak(char* &n);
This is never going to work. The whole idea of a class should mean that it knows how to take care of it's own behaviour. Consider what you're trying to do here, and how this would work/look/be easy to read in a real world application. Each of your classes should have it's own 'speak' function, in the class, which 'speaks' woof or meow. The common way to do this is to have them derive from an abstract base class called Animal, then you can make an Animal * into a Dog or a Cat, and it will know how to speak. If you don't need this behaviour, then just put the speak() methods in the classes and call them from there.
void main()
{
CCat cat1; // 2 instantiations one of cat one of dog
CDog dog1;
As an aside, this comment is unnecessary. A good comment would explain *why* you've created this variables/what they are for/etc., not repeat the obvious.
I hope that helps. If not, just ask again and I'll be happy to further clarify
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
thank you so much for the swift reply, I'm glad I'm not the only one up
browsing the boards. I agree with all the points you made, and it certainly
is quite easier to handle with separate, 1 class called functions.
Unfortunately for me, the book I'm using seems to think it is a simple
exercise, and the parameters are quiet clear. I must perform it as I posted
it to the board. I played with the pointer to the memory location, like you
first suggested, though only briefly. I will go back and try it again. The one question that keeps popping into my mind isn't how to overload the functions. It is how to pass the different arguments. If I can figure out how to differentiate which class object I am passing, then it can work. *deep, deeeeeep sigh*
Much Appreciatively,
Jason K. Dove
|
|
|
|
|
You *could* put a function in to the cat/dog classes that tells you what type of animal it is, and ( again ) derive from a base class. You could also use Run Time Type Identification. This is almost *always* a terrible idea, and I'm wondering why this book wants you to do things in such an ugly manner. It's not that it *can't* be done, it's that there is no reason why it *should*. If you're passing in the name of the animal and the cat/dog classes are visible to the function, then it is also easy - just write one function and check the name passed in for a known list of cats and dogs. Again, not extensible or practical, but it works in the scope of the example you're working with.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I got it. Thank you for all your help.;) It help to have perspective
Dove
#include <iostream.h>
#include "Cat.h"
#include "Dog.h"
void speak(CCat c);
void speak(CDog d);
void main()
{
CCat cat1;
CDog dog1;
cat1.catname = "Felix";
dog1.dogname = "Fido";
speak(cat1);
speak(dog1);
}
void speak(CCat c)
{
cout << c.catname << " says meow " << endl;
}
void speak(CDog d)
{
cout << d.dogname << " says woof " << endl;
}
|
|
|
|
|
Why don't you use a dummy argument in the second speak function i.e. to overload it like it is used for pre/post increment/decrement operators
void speak(char *str); //For cat object
void speak(char *str, int dummy);//For dog object
Really speaking an elegant solution is as Christian suggested using inheritance / virtual functions...
---------------------------
Atul
|
|
|
|
|
I understand you're suggesting this as a last resort to try and get the desired behaviour, but I just *have* to say for the record that I thought this to be fairly obvious, but too ugly to suggest
I realise you're not suggesting it as a real world solution, so please don't be offended
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|