|
|
can anyone hel me writng d code for drawing butterfly in c grahics which can run in turbo c
|
|
|
|
|
aviparida wrote: can anyone hel me writng d code for drawing butterfly in c grahics which can run in turbo c
Why do you keep repeating this question? If you want to draw a butterfly then I would suggest you get some books and learn about graphics programming.
|
|
|
|
|
See for instance [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
I got the process ids of the excel application instances and I need to get windows handler for that.
I tried with AccessibleObjectFromWindow function as below, but I'm getting E_FAIL in hr. Any help is appreciated. Thanks in advance.
HWND hwnd = (HWND)FindWindow(_T("XLMAIN"), NULL);
Excel::Window* pWindow = NULL;
HRESULT hr = AccessibleObjectFromWindow(hwnd, OBJID_NATIVEOM, __uuidof(Excel::Window), (void**)&pWindow);
|
|
|
|
|
If the excel is executed by you, you can get more info by CreateProcess() to run the excel.
or when multiple excels are running, which one you can get?
|
|
|
|
|
Main aim is to get the window handlers of the existing excel application instances. If there are two excel applications opened, I need to get the window handlers for those two instances. From the window handlers, I need to get excel application pointers. Hope you understood the scenario. Pls let me know if you need more clarification
|
|
|
|
|
I did something else, hope it help.
EnamWindows() can get all top level windows, in your case, excel is top one, maybe you can use the function to get more info to find excels.
|
|
|
|
|
 I tried with EnumWindows function also. Below is the complete code. Please mention, if I missed anything.
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
DWORD dwThreadId, dwProcessId;
HINSTANCE hInstance;
char String[255];
HANDLE hProcess;
dwThreadId = GetWindowThreadProcessId(hWnd, &dwProcessId);
}
int _tmain(int argc, _TCHAR* argv[])
{
HWND hwnd = (HWND)FindWindow(_T("XLMAIN"), NULL);
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return 1;
cProcesses = cbNeeded / sizeof(DWORD);
for (i=0; i<cProcesses; i++ )
{
if( aProcesses[i] != 0 )
{
TCHAR szProcessName[MAX_PATH] = _T("<unknown>");
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, aProcesses[i] );
if ( NULL != hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if( EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName, sizeof(szProcessName)/sizeof(TCHAR) );
if(_wcsicmp(szProcessName,L"EXCEL.EXE") == 0)
{
cout<< szProcessName << "--" << aProcesses[i] <<endl;
Excel::Window* pWindow = NULL;
pid = aProcesses[i];
EnumWindows( EnumWindowsProc, NULL);
HRESULT hr = AccessibleObjectFromWindow(hwnd, OBJID_NATIVEOM, __uuidof(Excel::Window), (void**)&pWindow);
if (hr == S_OK)
{
}
}
}
}
_tprintf( TEXT("%s (PID: %u)\n"), szProcessName, aProcesses[i] );
CloseHandle( hProcess );
}
}
return 0;
}
|
|
|
|
|
NarVish wrote: ...and I need to get windows handler for that.
What's a window handler?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I suggest you DO NOT ask your silly questions everywhere.
If you don't know what a window handle is, you still have a choice: shut up.
|
|
|
|
|
a process created a thread (say thread-a), if something happens in thread-a, the thread calls process, then process creates another thread thread-b.
thread-a and thread-b must be in same thread level.
how to general the thread-to-process call? PostThreadMessage() can be a choice, is there other simpler ways than PostThreadMessage()? or PosttThreadMessage() is the easist way in the case?
|
|
|
|
|
When you say a process, there is a main thread in the process.
The main thread creates thread-a.
The thread-a needs to communicate to the main thread to create the other thread.
You can do this using events.
Create an event in the main thread using CreateEvent .
The main thread can then wait for the event to be signaled using WaitForSingleObject .
The other threads can then use SetEvent to signal this event.
If your main thread is a UI thread, you will need another dedicated thread to wait for the event to become signaled so that the UI thread is not blocked.
But I believe PostThreadMessage is a better way to do this.
If your process has a window, you can also use PostMessage to the main window to achieve this.
|
|
|
|
|
I find 2 group of raw socket functions, one is basic kind, another one starts with WSA..., such as accept() and WSAAccept().
I am wondering that if second group (WSA...) is just implemented from basic group to offer some user-convenience, or it is rebuilt with more efficient functionalities?
in raw socket, which group is better from send-receive communication view (i.e. speed)?
|
|
|
|
|
includeh10 wrote: I find 2 group of raw socket functions, one is basic kind, another one starts with WSA.
The WSA functions are the Windows Socket 2 implementation, and just offer some enhanced functionality. They are all described in the MSDN documentation[^]. As far as I am aware the differences in implementation are unlikely to affect the speed.
|
|
|
|
|
Named IP is in english characters, such as "www.hello.abc.efg" - how to convert it to digital IP, such as "196.23.72.90"?
my usage is for raw socket, I did a test, the function inet_addr(...) can change only digital IP address, correct?
|
|
|
|
|
You're going to want to look into DNS lookups, which change human readable URLs, e.g. www.codeproject.com (what you've called a named IP, which isn't strictly correct) in to IP Adresses (what you've called digital IP).
|
|
|
|
|
you are right, named and digital IPs are defined by myself, I don't know how to call them.
|
|
|
|
|
includeh10 wrote: Named IP is in english characters, such as "www.hello.abc.efg" - how to convert it to digital IP, such as "196.23.72.90"?
The former is referred to as the host name while the latter is referred to as as IP dotted address. To get one from the other, you can use gethostbyname() and gethostbyaddr() . Both, however, have been deprecated by getnameinfo() .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
We can use PostMessage() to post integer to HWND if a window handle is valid, but how to post a message to a class object if without HWND?
The story looks like:
MyClass my;
void MyClass::Send()
{
post_message(100);
}
void MyClass::Receive()
{
switch(...)
{
case 100:
....
break;
}
}
how to implement the user function post_message(100)?
|
|
|
|
|
includeh10 wrote: how to implement the user function post_message(100)?
You have to build (or use and existing) communication path between the two objects. Do both objects exist in the same application and thread, or are these disconnected objects?
|
|
|
|
|
They are in same app, sender is in a thread, receiver is in main process - not in thread.
Any more info to implement?
|
|
|
|
|
I am not sure if this is an answer to your question but take a look at PostThreadMessage[^], you do not need to have a window for that, only a message queue in the given thread. You could use that + somekind of mechanism to route the incoming message to the correct instances, like have some identifier or handle in the wParam and the sent integer in the lParam, then on the receiving side you use wParam to identify the instance and call some member function feeding it lParam. Be careful with posting because it might happen that the targeted object gets destroyed before the message arrives and then when you try to call the method of the destroyed instance you get a crash. This of course depends on the implementation. Good luck.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I agree, this seems the optimum solution.
|
|
|
|