|
Err, unless I'm completely mistaken, ALL windows are created with the CreateWindow() function. I don't think there's another way. Even MFC uses it.
There are several books around on plain Win32 programming, but they might not be in print anymore. Try an Amazon search for "Win32".
J
|
|
|
|
|
Hi,
Is there anyway to monitor an already opened serial port's activity?
Any help would be highly appreciated,
Cheers,
Mehdi
|
|
|
|
|
Hmmm, I would propose to write a kind of driver which grabs the data flow between the application and the rs232-driver.
There are many ways to do that. If you are not really in writing win32 drivers try api-hooking. That means you have to do a kind of overwriting functions used to handle the serial port like CreateFile(), ReadFile(), WriteFile() and so on.
If you did the application doesn`t really call the functions from user32.dll or whatever but yours, keep the data and then call the original functions from system dlls and no one will worry.
Take a look at "Programming Applications for MS Windows" by Jeffrey Richter - you will find some chapters about api-hooking, dll injecting and things like that.
So far ...
CU Mario ///
---------------------------------
www.klangwerker.de
Look out for free Win32
Serial Communication Module
for VC++ or Borland C++ Builder
---------------------------------
|
|
|
|
|
This link could maybe get you started?
Click here
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
Hi,
I´m running Ms Word embedded, and I need to resize and move the Word window to make it fit in a place but...
I have a problem, when Word starts by default maximized there is no way to resize it ( even shows an error message telling that the window is maximized...), I have Tried this code:
m_app.CreateDispatch("Word.Application")
oDocs = m_app.GetDocuments();
oDoc = oDocs.Add(vOpt, vOpt, vOpt, vOpt);
(...)
m_app.Activate();
oDoc.Activate();
m_app.SetWindowState(wdWindowStateNormal);
m_app.SetLeft(93);
m_app.Resize(677, (szScreen.cy - 30));
But it shows the fu... message..., Thanks in advance
Braulio
|
|
|
|
|
Hello Braulio, that Word Automation thing must be a real pain in the ass. I know close to nothing about the subject, but from the similar code I've seen on the net, maybe you should try calling WindowState(wdWindowStateNormal) on oDoc before doing the same with m_app . If what I'm saying is absolute nonsense, please accept my apologies
Good luck!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hola Joaquin !, Gracias por la info !
The thing was to call activate and SetWindowState before any SetTop or Left or... ( and... sh*t I forgot a SetTop(0)... in the code somewhere... ).
But anyway Automation and Office thing is a real pain in the ass... we are having a lot of problems here with that ( it´s a nightmare when you try to run the same things with 97 or 2000, and for some stuff... it´s like... well Word do what you want....).
Thanks again and Seeya !
Braulio
|
|
|
|
|
can anyone give some advice how to debug a service running on win2k. i tried this thing adding a debugger value to the registry key
"Image File Execution Option"
but i didn`t get it to run in the debugger at all.
What is the value I have to add to this key if I want to use the VC++ Debugger ?
CU Mario ///
---------------------------------
www.klangwerker.de
Look out for free Win32
Serial Communication Module
for VC++ or Borland C++ Builder
---------------------------------
|
|
|
|
|
When I want to step into a service, I use the task manager. Select the service .exe and click Debug from the context menu.
Hope this helps,
Bill
|
|
|
|
|
Does realloc free memory if it fails?
according to msdn HeapReAlloc does not free memory and the original pointer/handle are still valid.
char* pTemp = (char*)realloc(m_pMem, 100); }
testing the function with either try/catch or NULL return to indicate a failure, would the following be acceptable?
m_pMem = pTemp;
I'm assuming this works with HeapReAlloc() but i can't find anything that says realloc does the same...?
TIA
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
as i remember, realloc stamps on your pointer if it fails, so yeh i used to do something like
//orig mem
pMem=malloc(42);
...
//need more?
pTry=realloc(pMem,142);
if (pTry)
{
pMem=pTry;
}
else
{
MessageBox(0,"no more mem, but i'll bash on regardless",0,0);
// but pMem is still valid (unless instead of 142 you sent zero!)
}
|
|
|
|
|
the temp return is working i just wanted to know if maybe i was seeing things and if it's really acceptable.
But if you've done it and it worked and it's working for, then i guess it must work.
None of the examples i've seen show testing the return of realloc/HeapReAlloc so i dunno what i'm suppose to think.
if anything they all
if(!ret) AfxMessageBox(" ")
not exactly the direction i want
Thanx again! and for the speedy response
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
realloc returns a void pointer to the reallocated (and possibly moved) memory block. The return value is NULL if the size is zero and the buffer argument is not NULL, or if there is not enough available memory to expand the block to the given size. In the first case, the original block is freed. In the second, the original block is unchanged.
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
So realloc could be used as a substitute for free..? I did not know that...cool
So it is acceptable to do what i was doing and Brandy has suggested is possible...?
store the return in a temp and copy the temp to the original if successful...?
Thanx again
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
Yup What is Brandy wrote is right.
But don't understand why to use ralloc to free the memory? lol
And HeapReAlloc() is called inside realloc()
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
hi guys,
i am trying to load the data of a file which is 100MB large in to a List Control. But during the loading Procedure the app does not respond anymore. If i use i a file which is not so large, it works fine. How can i solve the prob ?
I am using CStdioFile
Best Regards
Sonu
|
|
|
|
|
i don't know of any restriction on bytes or items in a list control, but there probably is one, unintended perhaps.
do you really want all that stuff in one list? it's not gonna be much use for navigation. if you just want the data available to your app, store it in some other structure (e.g. write a list class) or if you want the user to be able to browse it, perhaps a tree view control (include component MS Forms 2)?
hope that is some help.
|
|
|
|
|
To make a different thread and load the file inside this thread. Here is an example:
This is the loading thread function:
UINT LoadFileFunc(LPVOID lParam)
{
CListCtrl* pCtrl = (CListCtrl*)lParam;
CString csLine;
while(f.ReadString(csLine)){
pCtrl->InsertItem(pCtrl->GetItemsCount(), csLine);
}
}
And below the code from OnInitDialog() function (or any other function you want to start loading file)
...
AfxBeginThread(LoadFileFunc, &m_wndYourListCtrl);
...
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
The above 2 messages are good suggestions, and definitely things to think about.
However, I've also come across this and one reason it took so long for me was because it was sorting on every AddString(). Uncheck the "Sort" box in the properties and see if that improves performance a little.
J
|
|
|
|
|
I draw my bitmap (OnDraw function) in my CScrollView derived class using StretchBlt function... I want to avoid flickering when resizing and scrolling view..
Can anybody help me?
|
|
|
|
|
did you handle the WM_ERASEBKGND - Message?
BOOL CMyView::OnEraseBkgnd(CDC* pDC)
{
return true;
}
(i had several problems doing this with ScrollViews.. but maybe you achieve this)
have a nice one
bernhard
Sometimes I think the surest sign for intelligent life elsewhere in
the universe is that none of them ever tried to contact us.
|
|
|
|
|
try double-buffering
www.klangwerker.de/developer/english/double_buf.htm
(Didn`t I see this post on www.codeguru.com )
CU Mario ///
---------------------------------
www.klangwerker.de
Look out for free Win32
Serial Communication Module
for VC++ or Borland C++ Builder
---------------------------------
|
|
|
|
|
Yep, take a look at a class called CMemDC, maybe this class can help you ( you can find that here or in CodeGuru).
HTH
Braulio
|
|
|
|
|
I've never used new and delete, but figured i'd give it a try cuz they seem easier to work with and are often recommended.
CHAR* m_pBuffer; //private member
SetSize(nSize) { m_pBuffer = new CHAR[nSize]; }
~CMyClass()
{ delete [] m_pBuffer; }
I call Set Size twice but if i call it more than once and run in debug mode i get memory leaks detected!!!
Can you not dynamically resize the m_pBuff more than once...?
Help please
TIA
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
For every new you must have a delete, because new allocates memory.
If you call SetSize() twice you will have two new, but only one delete in the destructor, hence the memory leak. If you have Stroustrups C++ programming language 3rd ed., I suggest you read chapter 6.2.6.
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|