|
chikach wrote: How I will know the source of the CTLCOLOR_EDIT message?
The second parameter.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
thank you
|
|
|
|
|
Hi ,
I need to insert PNG image in MFC dialog . I tried with picture box not helpful , as you know BMP can be achieved , but PNG I am difficulty to insert . Googled , not able to screw it . Kindly give your suggestion .
Thanks,
Tam
www.tamilselvan.zoomshare.com
|
|
|
|
|
Maybe some the the replies in this[^] thread will help.
|
|
|
|
|
hi,
below is the code , picture is not getting displayed .
CPic::CPic(CWnd* pParent /*=NULL*/)
: CDialog(CPic::IDD, pParent)
{
/*CString csfilename;
csfilename.Format("C:\\warningIcon.png");*/
image.Load(_T("C:\\warningIcon"));
}
CPic::~CPic()
{
}
void CPic::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
void CPic::OnPaint()
{
image.Load(_T("C:\\warningIcon"));
/*PAINTSTRUCT ps;
CDC * drawDC = BeginPaint(&ps);
CRect rcClient;
GetClientRect(&rcClient);
image_.TransparentBlt(*drawDC, rcClient, CRect(0, 0, image_.GetWidth(), image_.GetHeight()), image_.GetPixel(0, 0));
EndPaint(&ps);*/
}
www.tamilselvan.zoomshare.com
|
|
|
|
|
Hi
I'm trying to write my own debugger I have
most the kinks squared away with the exception
of a few namely I am trying to re-create the
yellow arrow which follows you along when you step
through code
1) I was not quite sure if it's a function of a cursor
or a owner draw control
I had code to manipulate the cursor ::onsetcursor
which I had gotten to position the cursor
however when I added code for a custom
cursor LoadCursor(..... ".cur")
I followed all the steps putting in my resource file
then Setcursor after Load got all good return codes
but my new yellow cursor failed to appear
I am looking for some insight if I am on the correct path
Rhankx
|
|
|
|
|
if i had to guess, i'd say it's just a bitmap they draw on the editor window at the appropriate spot - neither cursor nor custom control.
|
|
|
|
|
Yeah you are probably right doesn't fit into any of the predefined windows class
I guess if you have a white rectangular background for the arrow you van use bitblt to move it along
|
|
|
|
|
This is a tough one. I have a process running in a console that sometimes "freezes" when trying to read data from serial port (or USB).
The issue only happens if the console does not have focus. If i click on the console so it has focus, the serial data starts coming in again. If the console has focus all the time, the issue never occurs.
It doesn't look like console focus can be detected with SetConsoleCtrlHandler or SetConsoleMode so the question is...
How can a console having focus effect serial port I/O? It doesn't look like a timing issue with console output messages.
|
|
|
|
|
Hi,
No idea if any of this lot is any good, but here are some things I'd try in the same situation:
- Does the slowdown happen with a /subsystem:windows application as well as a console one? If it does then it might be due to threads changing priority when an application is minimised.
- Is your serial I/O code in it's own thread? Normally I wouldn't advocate spinning off threads wily nilly but if the I/O is in it's own thread you don't have to worry about the UI thread being blocked in a message loop somewhere and not able to read from the serial port.
- Does the same thing happen if you run the app as an administrator or ordinary user? If it does there might be a security problem.
- Is there anything else that might be interfering with the serial I/O? Is the COMM port used for anything else or have you several devices on the same USB hub?
Anyway, hope that's not a complete waste of time and there's something in there that might help you resolve your problem,
Cheers,
Ash
|
|
|
|
|
Thanks for the tips. The process is run as Administrator and I just confirmed all reads and writes are from same thread. Not sure about the interals of the USB hub... its an embedded system and serial ports and USB are not standard.
Any more ideas? This is a tough one and has me baffled. Maybe its something in the Windows kernel having to do with handling IO since I don't see a public API to listen to focus events for a console.
|
|
|
|
|
After a little more digging, there was another thread trying to do some occasional writes. The original code had a "read" lock and a "write" lock so it was designed to allow reads and writes at same time but doesn't seem to work reliably unless all I/O is synchronized (one lock for both reads and writes).
|
|
|
|
|
For example, if the user alt-tabs to the window.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
How about WM_ACTIVATEAPP[^] and/or WM_ACTIVATE[^]?
> 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. <
|
|
|
|
|
Thanks.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi All,
My problem is that the code no longer works under Windows 7/Vista when
called from within the limited user account. CreateFileMapping()
routine returns ERROR_ACCESS_DENIED (code 5) upon attempt to create
the file mapping object in global namespace.
I've searched the web and discovered that from Vista onwards,
Microsoft has changed the policy that affects who will be granted to
obtain SeCreateGlobalPrivilege and that is it impossible for any code
called from within the limited user account to create global objects.
Does anyone know how to work around this limitation? Any pointers on
how to make this code compatible with Windows 7/Vista would be highly
appreciated.
Thanks & Regards,
Uday.
|
|
|
|
|
Hello,
I have an application that import contacts from outlook contact directory.
there is a problem that when someone has a very big list of contacts the application get stuck for along time until it finish importing the contacts,
I moved the entire import code to a pthread that will handle the import so the application won't get stuck while it's importing.
to access outlook i'm using this code:
hr=pApp.CreateInstance(__uuidof(Application));
when this code is executed from within a pthread it fails, but when executed normally from the application everything is working fine,
Anyone know what causing this problem?
Thanks.
|
|
|
|
|
Does that CreateInstance require you to initialize COM before using it (CoInitialize/CoInitializeEx)? If yes, how did you initialize it?
> 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. <
|
|
|
|
|
No initialize is needed,
here is the code access the outlook:
void CXPowerUIView::importFromOutlook()
{
_ApplicationPtr pApp;
_ItemsPtr pItems;
MAPIFolderPtr pFolder;
_ContactItemPtr pContact;
HRESULT hr;
try
{
hr=pApp.CreateInstance(__uuidof(Application));
if (FAILED(hr))
{
MessageBox(_T("Unable to instantiate Outlook."),_T("Outlook Error"),MB_OK);
return;
}
...........
}
This are the 2 ways I call it:
direct:
importFromOutlook();
from thread:
outlookHandle = CreateEvent(NULL, FALSE, FALSE, NULL);
outlookImportThread = ys_thread_create(2000, OutlookThreadFunc, NULL);
void* OutlookThreadFunc(void* pParam)
{
pThisView->importFromOutlook();
return NULL;
}
only direct one is working :/
|
|
|
|
|
And what does the HRESULT hr tell you? Just a blindshot here, add this to your thread:
CoInitializeex(NULL, COINIT_MULTITHREADED); at the beginning and CoUninitialize at the end. Like:
void* OutlookThreadFunc(void* pParam)
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
pThisView->importFromOutlook();
CoUninitialize();
return NULL;
}
That _ApplicationPtr::CreateInstance is probably using COM and as far as i know you have to initialize COM in every thread you intend to use it in.
> 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. <
|
|
|
|
|
|
Hi,
I am working on Excel Automation Project.
using GetActiveobject , getting one instance of Excel.exe. But need to track/access any number of instances which are opened.
Initally I am checking all the processes in task manager, if Excel.exe is running, then I will loop through to get the active Excel object using GetActiveObject.
But only one instance I am able to access. How to track other instance of Excel.exe's.
Regards,
KTTransfer.
|
|
|
|
|
This code by a coder dude called NarVish gets the Windows Handles
from process id of excel instance instances.
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;
}
|
|
|
|
|
Do you need the COM instances or just the process handles?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
I need COM instance.
Excel::_ApplicationPtr.
|
|
|
|