|
Hello Larsson,
You should get the number of items using GetCount();
and then use GetText(int A, CString &CS);
Where A must be the index of the last item.
Where CS must be a receiver CString.
Hope this helps.
|
|
|
|
|
I cant get this to work, can you please typ a exemple here so I can see.
I hace try to use this,
iGo = m_AddLogg.GetCount();
m_AddLogg.GetText(iGo, sText);
But this dont make me go down in the list. Note that sText in this case is emty.
|
|
|
|
|
Larsson wrote: iGo = m_AddLogg.GetCount();
m_AddLogg.GetText(iGo, sText);
Index is zero based, so you need to use following code,
iGo = m_AddLogg.GetCount();
m_AddLogg.GetText((iGo-1), sText);
|
|
|
|
|
Weekend, sorry, I hope that the answer from prasad_som has been useful.
Good luck...
|
|
|
|
|
Please help me,
When does user insert CD into driver CD.I want my program will automatically detect and show all of them(file and folder) are showed in a listbox.
My program is written y MFC
Thank you very much.
|
|
|
|
|
You need to create an AutoRun.Inf file that will inform Windows which program to run when the CD is inserted into the drive.
You can have it run your special program with the list in it you want.
|
|
|
|
|
Forgive me is this is a stupid question, but I'm kinda new to DirectX. I'm drawing 2D images using textured quads. Is it possible to draw two textures at the same time onto a single quad? I could do this by swapping the texture and drawing the sprite twice, but surely there is a way to do this in one blow.
|
|
|
|
|
Hi
I have an SDI application. The CMainframe currently has a CSplitterWnd embedded in it. In order to prevent over-crowding, I would like to add a CTabCtrl to intervene in between the CMainframe and the CSplitterWnd, such that the first tab shows the CSplitterWnd, and the other tabs show different views, and the user can move between the views without the views re-initialisaing. (Much like the "Contents / Index / Search / Favourites" tabs in the help system of VC++.)
What's the simplest way to achieve this please?
cheers,
Neil
|
|
|
|
|
I created a edit box just fine, but when i trying to select the text in it, the application for some reason does not do it, Im not sure what's missing. Here is the part of the code that Im talking about:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
#define IDC_MAIN_EDIT 1
#define IDC_SEDIT 2
#define IDC_BUTTON 3
HWND iEdit, rEdit, button;
switch(msg)
{
case WM_COMMAND:
if( wParam == IDC_BUTTON )
{
MessageBox( hwnd, "Button was clicked.", "Notification", MB_OK );
SetDlgItemText(iEdit, IDC_MAIN_EDIT, "testing");
}
break;
case WM_CREATE:
{
iEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", NULL,
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL |
}
...
}
when the WndProc receives the button message, a message box will appear saying i pressed the button, and the text in the iEdit control is suppose to be set to "testing" right? I really don't know what Im missing.
|
|
|
|
|
actually i just solved it myself. I didnt realize that when calling the SetDlgItemText(iEdit, IDC_MAIN_EDIT, "testing"); command, the first parameter corresponds to the parent window that the target edit box belongs to, no wonder we need to specify the edit box control id in the second parameter.
|
|
|
|
|
Can anyone provide a pointer to a class or library that supports adding extra buttons to a window's caption bar? Support for XP themes is required.
|
|
|
|
|
|
Hi all, I have a program that needs to pick up the contents of a
SysListView in another process. As you are all aware this requires me
allocating memory for my strings and the LVITEM structure in the other
process, then writing to them and sending the message and then reading
from them.
My code works, this might seem like a strange post but wait the plot
thickens.I tested this program on the task manager, It has four of
these SysListViews hanging around so It seemed as good a candidate as
any for my experiment. I watch the process locate the window (the title
changes so I had to do an enumwindows to find it) then I did an
enumchildwindows in order to find all the SyslistViews. Now I getting
somewhere I think to my self. I call my home-grown C dll with my window
handles and I get the thread and process responsible for these
critters.
I set my debug priveleges and and ask for my window handle "all
access". I allocate my memory watch my lil pointers come back and send
my message and readprocessmemory back into my address space, and
gleefully see the pointers filled with strings from the task manager.
This is where it gets interesting. I change my window title to the name
of the the title to the part of the name of the MDI window that I am
interested in. I get my handles, my process handle, and allocate my
memory, The first call works great, then the problems start ;( The
second call to virtualallocex succeeds but the pointes now have the
"bad ptr" following the address that was allocated, "that wasn't there
on the other window" I think to myself, and sure enough the strings
come back empty.
So I decide to google this one. Two days of googling and no cigar.
While googling I also decided that virtualallocex wasn't to be trusted
to find the base address in the other process, so I decided to walk the
vad and find my own address, this worked as well, and I locate memory
locations large enough to hold my memory , but still no cigar. It works
for the task manager but not the target program ;(
By this time I have almost read anything I could find on virtualallocex
and by passing most of the other virtual memory functions, I fiddled
with virtualqueryex and virtualprotectex, trying to find the problem.
FormatMessage came to mind pretty quickly but "The operation completed
successfully" isn't much help when trying to debug code that is
anything but successful.
At this point let me try to give you a description of my environment:
Window XP PRO SP2 latest updates.
VS.NET 2003, latest updates Enterprise Architect.
An old, P III 500 that if I could get the project to work would provide
me with some cash to buy one of the latest beasts available.
256 Mb of ram (always a drag that swapping ;()
The program I am trying to infiltrate is
EFX Navigator on www.efxgroup.com
For my info tell me what you need, I can get back to you.
Here is my soucre code, The first part is a VB.net module the second
part is as VC++ Win32 dll (hence why I posted here)
This code is anything but tidy but with all the debuging I'm doing
cleaning up old code (that works on the taskmanager and other programs)
doesn't seem like a good approach
Any way here it is:
VB.net Code First
-----------------------------------------------------------------------------------------------------------------------------------------------------
Imports System
Imports System.Runtime.InteropServices
Imports System.Text
Module MainModule
'FormatMessage
<dllimport("kernel32.dll", entrypoint:="FormatMessageA" ,="" _
="" charset:="CharSet.Ansi," exactspelling:="True," callingconvention:="CallingConvention.StdCall)"> _
Private Function FormatMessage( _
ByVal dwFlags As Int32, ByVal lpSource As Int32, _
ByVal dwMessageId As Int32, ByVal dwLanguageId As Int32, _
ByVal lpBuffer As StringBuilder, _
ByVal nSize As Int32, ByVal Arguments As Int32) As Int32
End Function
Private Const FORMAT_MESSAGE_ALLOCATE_BUFFER As Long = &H100
Private Const FORMAT_MESSAGE_FROM_SYSTEM As Long = &H1000
Private Const FORMAT_MESSAGE_IGNORE_INSERTS As Long = &H200
Private Declare Function GetLastError Lib "kernel32.dll" () As
Integer
'declare API functions
Private Delegate Function EnumChildProcDelegate _
(ByVal hWnd As IntPtr, _
ByVal lParam As Integer) As Boolean
Private Declare Function EnumChildWindows Lib "user32" _
(ByVal hWndParent As IntPtr, _
ByVal lpEnumFunc As EnumChildProcDelegate, _
ByVal lParam As Integer) As Boolean
Declare Function GetClassName Lib "user32.dll" Alias
"GetClassNameA" _
(ByVal hwnd As IntPtr, _
ByVal lpClassName As StringBuilder, _
ByVal nMaxCount As Long) As Long
Private Declare Ansi Function FindWindow Lib "user32" Alias
"FindWindowA" _
(ByVal lpClassName As StringBuilder, ByVal lpWindowName As
StringBuilder) As IntPtr
Public Declare Sub GetWindowText Lib "user32.dll" _
Alias "GetWindowTextA" (ByVal hWnd As IntPtr, _
ByVal lpString As StringBuilder, _
ByVal nMaxCount As Integer)
Private Declare Function SendMessage Lib "user32" Alias
"SendMessageA" _
(ByVal hwnd As IntPtr, ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As String) As Integer
Public Declare Function GetWindow Lib "user32.dll" _
Alias "GetWindow" (ByVal hwnd As Integer, _
ByVal wCmd As Integer) As Integer
'Top Level enumeration
Public Delegate Function EnumWindowsCallback(ByVal hWnd As IntPtr,
_
ByVal lParam As
Integer) As Boolean
Public Declare Function EnumWindows Lib "user32.dll" _
Alias "EnumWindows" (ByVal callback As EnumWindowsCallback, _
ByVal lParam As Integer) As Integer
<dllimport("user32.dll", entrypoint:="EnumWindows" ,
setlasterror:="True," _
="" charset:="CharSet.Ansi," exactspelling:="True," callingconvention:="CallingConvention.StdCall)"> _
Public Function EnumWindowsDllImport(ByVal callback As
EnumWindowsCallback, _
ByVal lParam As
Integer) As Integer
End Function
'My DLL Declares
Private Declare Function CopyListViewToListBox Lib "Extract Data
Library.dll" _
Alias "CopyListViewToListBox" (ByVal SourceHwnd As IntPtr, ByVal
TargetHwnd As IntPtr, _
ByVal Append As Boolean) As Integer
Private Declare Function FillListBox Lib "Extract Data Library.dll"
_
Alias "FillListBox" (ByVal targetHwnd As IntPtr, ByVal item As
String, _
ByVal subitem As String, ByVal Append As
String) As Integer
'Variables
Dim iFound As Int32
Dim aihWnds As ArrayList
Private Const WM_GETTEXT = &HD
'Listbox Functions
Private Declare Function LockWindowUpdate Lib "user32" (ByVal
hwndLock As IntPtr) _
As Long
'Listbox Constants
Const LB_RESETCONTENT = &H184
Const LB_GETCOUNT = &H18B
Const LB_GETTEXT = &H189
Const LB_ADDSTRING = &H180
Const LB_GETITEMDATA = &H199
Const LB_SETITEMDATA = &H19A
Function GetGlass(ByVal hwnd) As String 'classe de la fenetre
Dim sClassName = New StringBuilder(256)
GetClassName(hwnd, sClassName, 256)
sClassName = Left$(sClassName, InStr(sClassName, Chr(0)) - 1)
Return sClassName
End Function
Function GetCaption(ByVal hwnd As IntPtr) As String 'titre du
document
Dim sCaption = New StringBuilder(256)
GetWindowText(hwnd, sCaption, 256)
sCaption = sCaption.ToString
If Len(sCaption) > 1 Then
Debug.WriteLine(sCaption)
If (InStr(sCaption, Chr(0)) - 1) > 0 Then 'trim null
sCaption = Left$(sCaption, InStr(sCaption, Chr(0)) - 1)
End If
End If
Return sCaption
End Function
Function GetCaptionFromMessage(ByVal hwnd) As String 'texte titre
fenetre
Dim sCaption = New String(Chr(0), 100)
Dim retval = SendMessage(hwnd, WM_GETTEXT, 100, sCaption)
sCaption = Left$(sCaption, InStr(sCaption, Chr(0)) - 1)
Return sCaption
End Function
Function EnumChildrenProc(ByVal hwnd As IntPtr, ByVal lParam As
Integer) As Boolean
Dim retval As Long
'error handling goes here good old formatmessage from system
Dim ClassName As New StringBuilder(256)
retval = GetClassName(hwnd, ClassName, 256)
If ClassName.ToString = "SysListView32" Then
'found listbox
Debug.WriteLine(hwnd)
'FillListbox(hwnd)
MainModule.aihWnds.Insert(iFound, hwnd)
iFound = iFound + 1
End If
'If iFound = 1 Then
'Return False 'Found Both of the Listbox Stop enumeration
'Else
Return True 'Still haven't got them both
'End If
End Function
Sub GetListBoxes()
'need to loop through all windows to get the first characters
and compare to level II ...
'Dim sWindowCaption = "Windows Task Manager"
'Dim hwnd = FindWindow(vbNullString, sWindowCaption)
Dim proc As New EnumWindowsCallback(AddressOf
MainModule.EnumWindowProc)
EnumWindows(proc, 0)
'DuplicateListBox(MainForm.Listboxes(0).Handle,
MainForm.Listboxes(1))
End Sub
Private Function EnumWindowProc(ByVal hwnd As IntPtr, ByVal lParam
As Integer) As Boolean
If InStr(GetCaption(hwnd).ToString, "Level II") Then
ProcessEFXChildren(hwnd)
Return False
End If
Return True
End Function
Private Function ProcessEFXChildren(ByVal hwnd As IntPtr)
iFound = 0
aihWnds = New ArrayList
Dim i As Integer
Dim proc As New EnumChildProcDelegate(AddressOf
MainModule.EnumChildrenProc)
Dim retval = EnumChildWindows(hwnd, proc, 0&)
For i = 0 To iFound - 1
CopyListViewToListBox(aihWnds(i),
MainForm.Listboxes(0).Handle, False)
Next
End Function
End Module
---------------------------------------------------------------------------------------------------------------------------------------------
VC++.NET DLL CODE
// Extract Data Library.cpp : Defines the entry point for the DLL
application.
//
//Defines
#define WIN32_LEAN_AND_MEAN
//Includes
#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>
#define My_EXPORTS //Define in order to
export functions
#include "Extract Data Library.h"
#include <string>
#include <cstdlib>
#include "stdlib.h"
//Declares Exported Functions
//Delcares Internal Functions
DWORD DoFormatMessage();
DWORD DoDebugFormatMessage();
int SetDebugPrivileges(void);
MEMORY_BASIC_INFORMATION WalKingTheVAD(HANDLE hProcess, DWORD
RequiredSpace);
//Exported Variables
//Global Variables
//DLL ENTRRY POINT
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
//Code Starts here
My_API_Export int __stdcall CopyListViewToListBox(HWND SourceHwnd, HWND
TargetHwnd, BOOL Append)
{
SetDebugPrivileges();
HWND listview= SourceHwnd;
int count=(int)SendMessage(listview, LVM_GETITEMCOUNT, 0, 0);
int i;
LVITEM lvi, *_lvi;
char item[512], subitem[512];
char *_item, *_subitem;
unsigned long pid;
HANDLE process;
MEMORY_BASIC_INFORMATION mbi;
LPVOID BaseAddress = 0;
GetWindowThreadProcessId(listview, &pid);
//process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|
//
PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, pid);
process=OpenProcess(PROCESS_ALL_ACCESS,false, pid);
//DoFormatMessage();
mbi = WalKingTheVAD(process, (DWORD)(sizeof(LVITEM)) );
if (mbi.BaseAddress ==NULL)
{
MessageBox(NULL, "Insufficient Memory in Target Process
to Extract
Data","Fatal Error", MB_ICONERROR);
return -1;
}
BaseAddress = mbi.AllocationBase;
_lvi=(LVITEM*)VirtualAllocEx(process, BaseAddress,
sizeof(LVITEM),
MEM_COMMIT, PAGE_READWRITE);
if (_lvi == NULL) DoFormatMessage();
mbi = WalKingTheVAD(process, (DWORD)(100) );
if (mbi.BaseAddress ==NULL)
{
MessageBox(NULL, "Insufficient Memory in Target Process
to Extract
Data","Fatal Error", MB_ICONERROR);
return -1;
}
BaseAddress = mbi.AllocationBase;
_item=(char*)VirtualAllocEx(process, BaseAddress, 100,
MEM_COMMIT,
PAGE_READWRITE);
DoFormatMessage();
_subitem=(char*)VirtualAllocEx(process,NULL, 100, MEM_COMMIT,
PAGE_READWRITE);
DoFormatMessage();
/*
_lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM),
MEM_COMMIT, PAGE_READWRITE);
_item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT,
PAGE_READWRITE);
_subitem=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT,
PAGE_READWRITE);
*/
lvi.cchTextMax=512;
for(i=0; i
|
|
|
|
|
Is the following utility successful in getting the contents of the list view?
FWIW, here is a clever utility that copies the text of another process's controls to the clipboard. The controls that are supported are Edit (including obscured password edits), Static, Headers, Listview, ComboBox and ListBox. Source code (GPL'd) is included: "Control Content Saver" by Jacquelin Potier at http://jacquelin.potier.free.fr/controlcontentsaver/[^]
If the code at the above site works, whereas yours doesn't, then compare code.
If the code at the site doesn't work either, then you might not be looking at an ordinary list view control. Are you 100% certain that the windows class is SysListView(32)? Double-check with Spy++. If it's definitely a SysListView, then also check the style flags. Maybe it's an owner-data (i.e., a virtual list view) or owner-drawn, or both.
Mike
|
|
|
|
|
How can i invoke exe form cuurently running exe. After invoking i want to close the original exe.
|
|
|
|
|
kiranin wrote: How can i invoke exe form cuurently running exe. After invoking i want to close the original exe.
ShellExecute and DestroyWindow or PostQuitMessage
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
im doing a project where i have to insert the drive. before logging in to my OS i have to initialize the secutity.i used CoInitializeSecurity() function to register the security. but it returns some garbage value. the code i used is
hres = CoInitializeSecurity( NULL,-1,NULL,NULL, RPC_C_AUTHN_LEVEL_DEFAULT,RPC_C_IMP_LEVEL_IMPERSONATE,NULL,EOAC_NONE,NULL);
hres returns some garbage values as -24789156. can any one explain why this occurs and how to rectify this. thanx in advance.
|
|
|
|
|
Let me begin by saying I have written several significant scientific applications using IP sockets on a WAN. My socket implimentation uses the standard Berkley sockets (send, recv, etc.) from WinSock2 in an MFC application (Visual C++). Network operation is quite robust handling many connects / disconnects, TCP/UDP and very heavy traffic.
So where is the problem?
I don't believe what I have is the best solution possible. Every time I look at other possibilities I am inundated with:
o WSASend, WSARecv, etc, vs send, recv, etc.
o MFC CSocket vs CAsyncSocket
o overlapped, synchronous, non-blocking, ...
o use of IOCP
o and anon
My question is:
Is there one best reference that compares and contrasts all the myriad options available for socket programming in Visual C++ / MFC?
I will appreciate any advice!!!
-Obi Wan 2
|
|
|
|
|
With your experience I don't see any reason to use the MFC wrappers, especially CSocket.
You should also have a good grasp on blocking/non-blocking sockets.
Whether to use overlapped, synchronous, blocking, or unblocking all depend on the thread model
you're using. An IOCP uses all overlapped operations.
An IOCP works well for servers with many connections to avoid the 1 thread per connection
scenario. If you have 1000 simultaneous connections and there's only 4 processors on the server
then having 1000 threads is a waste of resources. An IOCP eliminates that waste by using a pool
of generic threads (the threads aren't associated with any connection).
Hope this helps a little.
Mark
*EDIT* Lots of info here: Windows Sockets 2[^]
-- modified at 20:08 Friday 26th January, 2007
|
|
|
|
|
Mark:
Thank you.
Yes, it helped quite a bit in that it confirmed my suspicions about CSocket and CAsyncSocket...and IOCP.
May I elicit a few more comments from you?
o In your example, 1000 threads serving 1000 connections makes a strong case for thread pooling (IOCP). It would be equally pointless to inherit the overhead of thread pooling for a single connection. Where do you see the break-even point? 10? 100? I know there can be no precise answer; it depends on many things, like processsor speeds, HyperThreading, Dual-core, multi processors, etc.
o Overlap, asynchronous and non-blocking kind of address the same issue--that being performance. What is the case to be made for each technique? Other than the thread pooling issue, is there a performance benefit over using non-blocking sockets and periodically polling them?
o What can you tell me about select, WSAAsyncSelect, etc.? I've had very limited success with these. It seems I need to make repeated calls to get the status, but when I read about things like WSAAsyncSelect I get the impression that the message is sent without having to poll for it.
-Obi Wan 2
|
|
|
|
|
Obi Wan 2 wrote: In your example, 1000 threads serving 1000 connections makes a strong case for thread pooling (IOCP).
It would be equally pointless to inherit the overhead of thread pooling for a single connection.
Where do you see the break-even point? 10? 100?
To me, the break-even point is at the number of processors on the machine. There's no reason
to have more threads than can be run concurrently. I get good results with IOCP and the number
of threads in the pool equal to number-of-processors * 2. This way there's a thread available
to start processing until it needs to wait for another thread to finish using a a relatively
slow-to-access shared resource (a database in my case). When another thread finishes, the next
thread is already waiting at the code that accesses the resource. I haven't yet been able to
thoroughly test performance using 1, 2, ... threads-per-processor to determine the best
performance but it's something that should be done.
I agree for a single connection an IOCP with a pool of threads would be pointless, unless you're
using the IOCP for other things besides socket I/O. IOCPs make a handy semaphore-like object
with no release count limit, but that's another topic altogether.
There's nothing wrong with using an IOCP with just one thread. If, for example, an app does many
socket sends that don't require a reply, then putting the messages in overlapped buffers and
sending using the IOCP can save coding time since IOCP has implemented queueing for you. The
one thread just cleans up the buffers when the IOCP is done with them (by deleting or maybe
returning them to a buffer pool). There's also the advantage in this scenario of being able
to turn off the socket's send buffering, since overlapped buffers hold the data - no need to
do an extra copy to the socket's send buffer.
Obi Wan 2 wrote: Overlap, asynchronous and non-blocking kind of address the same issue--that being performance.
What is the case to be made for each technique? Other than the thread pooling issue, is there a
performance benefit over using non-blocking sockets and periodically polling them?
I would say that it depends on the architecture of the code, specifically how threads are being
used. A single-threaded application using blocking sockets would perform poorly and if it had
a UI, the user experience would be horrible. Overlapped/asynchronous operations can help by
allowing processing to continue immediately after a socket operation is called. When the
operation finishes at a later time then the app is notified. Because the Windows Sockets
implementation is capable of being used event-driven, I think polling is completely unnecessary,
a waste of CPU cycles, and inefficient...which leads to the 3rd topic...
Obi Wan 2 wrote: What can you tell me about select, WSAAsyncSelect, etc.?
First, the only difference between WSAAsyncSelect and WSAEventSelect is the method that the app
is notified that a particular socket event occurs. WSAAsyncSelect uses regular Windows
messages (good for single-thread apps) and WSAEventSelect uses an event synchronization object
(good for multi-threaded apps). Waiting for FD_READ events is particularly useful because it
eliminates the need to poll for received data.
It's typically recommended that one thread be used for socket I/O. Sockets are not thread-safe
(although reading and writing simultaneously to a Windows Socket generally works, it's not
documented as being safe) so multiple threads would end up waiting to use the socket anyway.
For maximum efficiency using TCP it's most important to keep the receive buffer flushed,
otherwise performance drops significantly. If an app isn't able to process incoming data as
fast as it is received then the data should be queued/buffered for later processing by another
thread to allow the I/O thread to continue receiving data. Actually that applies to UDP as well
except that with UDP, if you don't receive datagrams fast enough, it only affects the receiving
end. With TCP the sender is affected because it knows the receiving end can't accept data so it
has to wait.
For more specific implementation details, I guess it comes down to what type of communication is
going on. Text data to/from a database requires a relatively simple implementation. Real-time,
high bandwidth data requires something more sophisticated. IOCPs are great for managing large
numbers of connections, such as with a large organization's database server or an HTTP server.
I'm no expert on this stuff. All my comments are based on experience - A major portion of my
application suite is real-time streaming of video/audio/device-control data mixed with database
communication. I've had the (un?)fortunate pleasure of re-writing my communication code
several times over the past few years trying different combinations of socket operations and
thread models.
Mark
|
|
|
|
|
I have created a report list view with columns sized so horizontal scrollbar does not appear. I respond to the WM_SIZE message to change the column with, but sometimes a spurious horizontal scrollbar from appears. As soon as you try to use it, it goes away. (It also doesn't use themes in XP!)
I've tried several methods to stop this from happening, but am at a loss.
I even resorted to putting this in the OnSize() handler:
<code> if (m_listCtrl.m_hWnd)
{
DWORD style = GetWindowLong(m_listCtrl.m_hWnd, GWL_STYLE);
if (style & WS_HSCROLL)
SetWindowLong(m_listCtrl.m_hWnd,
GWL_STYLE, (style & ~WS_HSCROLL));
}
</code>
I can break on the SetWindowLong() call, but it doesn't actually get rid of the scroll bar.
-- modified at 19:01 Friday 26th January, 2007
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Joe Woodbury wrote: prevent a horizontal scrollbar from appearing in list view.
You may want to consider resizing the list view's column(s) to prevent the horizontal scrollbar from being displayed. This should be done when the list view's size changes. The disadvantage is that your users may often need to resize the columns manually.
It's less of an issue if the control has a single column, in which case the user will simply resize the application's window (or view).
/ravi
|
|
|
|
|
I guess I wasn't clear enough. I have sized the columns to fit without a horizontal bar being displayed. When sizing, though, a bar sometimes does appear. (And no, the users aren't going to be resizing the columns manually--just trust me on that.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Sorry, I should've read your message carefully.
You may want to try SetRedraw(FALSE); before resizing the columns, and SetRedraw(TRUE); followed by an Invalidate() and UpdateWindow() pair to force a clean repaint after the resize logic.
/ravi
|
|
|
|
|