|
I have a dialog with a list view control (CListCtrl ).
So, I want that the list view control never lost the selection! It should be allways one item selected!
It should be also be one item selected if the list view control lost the focus! When I set the LVS_SHOWSELALWAYS flag only draws a gray background on the item, I want that there is allways one item selected in blue (like in the CListBox ).
I tried to modify the NM_LISTVIEW struct during the OnItemchangingList1 function (= LVN_ITEMCHANGING ), but I have no idea how to change this struct.
Can anyone help me?
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
You can use the owner dran features. It mean that you can draw somethings yourself. Read the MSDN.
|
|
|
|
|
The way I do what you are asking is to use Owner Draw.
Here's how to do it.
1. Set the window style of the list control in your dialog resource to Owner Draw Fixed
2. Derive your own list control from CListCtrl
3. Override void CYourNewCtrl::DrawItem(LPDRAWITEMSTRUCT lpDIS)
Example
void CYourNewCtrl::DrawItem(LPDRAWITEMSTRUCT lpDIS) <br />
{<br />
CDC dc;<br />
dc.Attach(lpDIS->hDC);<br />
int nCol;<br />
LVCOLUMN lvc;<br />
lvc.mask = LVCF_WIDTH|LVCF_FMT;<br />
<br />
CRect rc = lpDIS->rcItem;<br />
<br />
COLORREF m_crFG = GetSysColor(COLOR_WINDOWTEXT);<br />
COLORREF m_crBG = GetSysColor(COLOR_WINDOW);<br />
COLORREF m_crSelBG = GetSysColor(COLOR_HIGHLIGHT);<br />
COLORREF m_crSelFG = GetSysColor(COLOR_HIGHLIGHTTEXT);<br />
<br />
BOOL bSelected = GetItemState(lpDIS->itemID,LVIS_SELECTED);<br />
BOOL bFocused = GetListCtrl().GetItemState(lpDIS->itemID,LVIS_FOCUSED);<br />
<br />
int nOldMode = dc.SetBkMode(TRANSPARENT);<br />
<br />
dc.FillSolidRect(rc, bSelected?m_crSelBG:m_crBG);<br />
<br />
COLORREF crText = (bSelected?m_crSelFG:m_crFG);<br />
<br />
dc.SetTextColor(crText);<br />
<br />
<br />
<br />
dc.SetBkMode(nOldMode);<br />
<br />
dc.Detach();<br />
}<br />
Kind regards,
Tim
|
|
|
|
|
Thanks! I will try it!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Dear Friends,
Good Day Everybody...
I built an application (SDI)and i need to open a window or a dialog (more than one at a time) to view some data.
the data will differ from one window to another, thats why i need to open more that one window how i can do this Modal dialogs cant do this plz help.
Best Regards,
zakarni
|
|
|
|
|
Modeless dialogs should do the trick. Store your dialog as a member variable, and then call ( from memory ) Create instead od DoModal, and ShowWindow. I use pointers, and do this in the dialogs constructor
if (Create(IDD, pParent)) ShowWindow(SW_SHOW);
That's from memory, but it's something like that.
Of course if you use pointers, make sure to set them to NULL when you delete them, and call DestroyWindow on them first. Or just call ShowWindow(SW_HIDE); to hide them. I use ::IsWindowVisible((m_pDialog); to see if a window exists and is visible.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
But better style were views.
|
|
|
|
|
i have two views in the program one uses the treeview and the second uses a listview now each item in the list view should be opened in a seperated window.
this is what i was asking i might open moore than one item from the list how can i do this.
thanks,
Best Regards,
Zakarni
|
|
|
|
|
Hello Friends,
I have a very intresting question .
The problem is that i have written an application(.exe) it uses a .dll file i.e few functionality are provided in the dll file . as the file is used it is loaded dynamically now the problem is that i want to change this dll without unloading the application is this possible??? i have done some changes in the dll so without unloading the application can i unload the dll and again reload it. but as the dll is loaded it is not replaced by the new dll in that folder .
can any one suggest me a option for it????
Tryout are also welcome.Please suggest some technique to do this
|
|
|
|
|
If you close the dll, you can replace it. So long as the code is using the dll ( i.e. has it open ), you can't.
Or am I misunderstanding you ? You have the dll and just want to swap them without turning your main app off, right ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
actually u got the point right i have to change the dll and not swap.see i have a folder called ABC in this abc folder i am having my application app.exe and all called xyz.dll.
now my applixcation app.exe is running and it is using the xyz.dll.so the xyz.dll is loaded .Now i want to replace this xyz.dll in the folder and that loaded in the application i.e is app.exe. is it possible???
thanks for prompt reply
|
|
|
|
|
FreeLibrary() is the opposite of LoadLibrary(). But it doesn't guarantee that the dll will be unloaded and unlocked.
Signature space for rent. Apply by email to....
|
|
|
|
|
i have to change the dll .see i have a folder called ABC in this abc folder i am having my application app.exe and all called xyz.dll.
now my applixcation app.exe is running and it is using the xyz.dll.so the xyz.dll is loaded .Now i want to replace this xyz.dll in the folder and that loaded in the application i.e is app.exe. is it possible???
yep freelibrary() is possible but i will have to stop the work done by the dll function for that tiome??? how to move ahed
|
|
|
|
|
hi,
in one procedure I post message to thread with wParam , the thread accepted my message, but wParam is corrupted.
Here is the code:
In the procedure
MsgParam *pSendParam=new MsgParam;
pSendParam->pBuf=pBuf;
pSendParam->nLen=nLen;
PostThreadMessage(tid,WM_HYDRO_RXD_ARRIVAL,(WPARAM)pSendParam,0);
In thread Function
case WM_HYDRO_RXD_ARRIVAL:
pRecParam=(MsgParam*)msg.wParam;
before PostThreadMessage , pSendParam is correct(in this case, it's f5f5090574a05200 ), but in case WM_HYDRO_RXD_ARRIVAL , the value is corrupted as 44bf4a5f01000000 ,
How to transfer data correctly?
Extreme programming. Do the No.1
|
|
|
|
|
appreciation for any information on this post.
Thanks
Extreme programming. Do the No.1
|
|
|
|
|
BTW: Your E-Mail address seems to be incorrect. I got an "Undeliverable Mail" message for steven_wng@sina.com on my previous post. Hope you check the forum as well
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
You are developing on Win64? Wow
Your problem sounds a bit strange. It should work as you described, I can't find anything conspicuous in your code. I would suppose a subtle side effect:
- Are you sure the value of WM_HYDRO_RXD_ARRIVAL is unique and you are not accidently catching the wrong message?
- Are you sure _W64 is always defined and really all data types are used as 64 bit types?
- Did you monitor any other side effects that look like memory corruption occuring somewhere in your app?
- Does the same problem appear in a small test app?
(Hm the above looks a bit like the generic "are you sure the power cable is plugged in" hotline answer )
Good luck!
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
the code is absolutely incorrect.
try to send an int
int i=5;
PostThreadMessage(tid,WM_HYDRO_RXD_ARRIVAL,(WPARAM)i,0);
it will be OK.
when u pass an object created by new, normally it can not be passed to another thread in the simple way.
i don't know how to do it, but i did similar thing in COM, if u know COM, try same idea that how COM passes object to another COM (they are in 2 threads).
good luck.
includeh10
|
|
|
|
|
What?
Sorry, includeh10, but you seem to completly misunderstood the concept of threads.
You can pass pointers between threads as long as you make sure they reside in the same process. All threads inside a process share the same address space, therefore any address reference is valid and accessable by every thread. Actually this easiness of inter-thread communication is the main reason we use threads instead of processes.
COM puts a lot of "magic stuff" (like apartments, free threaded marshaller, ...) around this, because it has to guarantee that it even works if both thread reside in different processes or even on different machines.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
i am pretty sure that an object can be past from one COM to another even 2 COM are in the same process (or create by same process).
as i said, i never use threads in this way, but i don't think the code would work.
anyway, do further test to get right answer.
good luck
includeh10
|
|
|
|
|
hi,
yeath, I really can pass int i through the gap,but can't pass a struct. I don't know why too. As far as COM is concerned, Inside COM and Essential COM is all what I have. I determined to check it out.
Thanks
Extreme programming. Do the No.1
|
|
|
|
|
Have you tried passing pSendParam through the LPARAM parameter?
PostThreadMessage(tid,WM_HYDRO_RXD_ARRIVAL,0,(LPARAM)pSendParam);
and changing your thread to this:
pRecParam=(MsgParam*)msg.lParam;
Kelly Herald
Software Developer
Micronpc, LLC
|
|
|
|
|
Hi
I'm working on drawing a custom button (its quiet complex as its not really a button)..
is there anyway to remove the flicker as the button is redrawn.. I guess you create a new bitmap or something draw to that and copy it over all when its drawn..
can anybody give me an idea about what function to call to make a chunk of memory (or bitmap) that I can get the DC off and then draw to it..
I'm not using MFC
Many thanks..
Chris
|
|
|
|
|
The best thing is to handle WM_ERASEBKGND and there draw a bitmap that you store internally onto the HDC. Do all your drawing to the bitmap, and only do one BitBlt to the button, on that message handler.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
There are samples in the MFC MSDN. You can there evaluate the principles.
I would do all drawing in a memory dc and if ready draw all to the screen.
|
|
|
|