|
sabdalla80 wrote: why it didn't work the first couple of times I tried it.
Obviously you didn't try it enough times!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am using a CListCtrl with 'LVS_ICON'.
In VS2003 the different icons in the ListCtrl could be selected that caused the default behaviour (Blue Selection-Box). In the newer version of the Visual Studio the Selection-Box does not appear and the icons disappear when selected.
Has anyone an idea what the problem might be?
|
|
|
|
|
The list view control is provided by the operating system,
not Visual Studio.
MrNyquist wrote: Has anyone an idea what the problem might be?
There's a problem in the code
What are all the styles used to create the control?
What does the code look like that adds items?
How are you providing images to the control?
etc...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: The list view control is provided by the operating system,
not Visual Studio.
OK ... but the problem with the ListCtrl occured with the change of the Visual Studio (change of MFC Version)...
Here some code:
The ListCtrl is created with:
m_ListCtrl.Create(WS_CHILD|WS_VISIBLE|LVS_ICON|LVS_ALIGNTOP|LVS_SINGLESEL|LVS_AUTOARRANGE, rect, this, ID_OFEN_LIST_CTRL);
The ImageList is created with:
m_ImageList.Create(m_nWidthIcons, m_nHeightIcons, ILC_COLOR32, m_nInitial, m_nGrow);
m_ListCtrl.SetImageList(&m_ImageList, LVSIL_NORMAL);
The items were added with the following code (item --> LVITEM):
item.mask = LVIF_IMAGE|LVCFMT_CENTER;
item.iItem = nIndex;
item.iSubItem = 0;
item.iImage = nIndex;
item.state = LVIS_FOCUSED;
m_ListCtrl.InsertItem(&item);
The images are drawn with a CBitmap object:
m_ImageList.Add(&bitmap, RGB(0, 0, 0));
|
|
|
|
|
Excellent info, thanks!
MrNyquist wrote: item.mask = LVIF_IMAGE|LVCFMT_CENTER;
LVCFMT_CENTER is for column definitions. That's going to mess something
up using it as an item mask! Remove that
MrNyquist wrote: item.state = LVIS_FOCUSED;
Not a problem, but this is doing nothing since you haven't specified the
LVIF_STATE mask.
I tested using your control styles with the LVCFMT_CENTER removed and it
worked fine (VS 2008 SP1, Vista Ultimate).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hmm just for the heck of it I looked at the values for
LVIF_IMAGE and LVCFMT_CENTER....they are the same, so even though
LVCFMT_CENTER is used incorrectly, it has no effect.
I'm unable to reproduce any problem using your code
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey Mark!
Thx for your efforts...
I found the mistake in my code.
The image list is now created with the following code:
m_ImageList.Create(width, height, ILC_COLORDDB|ILC_MASK, nInitial, nGrow);
The images were added with:
m_ImageList.Add(&bitmap, m_crFillColor);
'm_crFillColor' is the background color of the list control.
|
|
|
|
|
I need to write some projects both Vc6 and Vc8, so I'm searching to a way to easily convert a project between different compiler version.
I create the project in vc6, then I update it in vc8 correctly. And the program is everytime correcly compiled and run.
But the files and project are in the same folder, this is a problem because every project puts its output in the same Debub and Release subfolder.
A temporary solution is to "clean all" before compile, but i'm not sotisfied because it isn't easy to have the 2 version of the project opened at the same time.
The clean solution that I'm trying to use is to create some folders like
MyProjFolder
Sources (it contains every .cpp, .h and .rc files)
res
vc6 (it contains the project for vc6: files .dsw and .dsp)
Debug
Release
vc8 (it contains the project for vc8: files .sln and .vcproj)
Debug
Release
I linked all the resources (cpp and h files) in every project (contained into the Source folder) but when compiling this error comes:
fatal error C1083: Cannot open precompiled header file: '.\Debug/***.pch': No such file or directory
any tip?
Russell
modified on Wednesday, November 12, 2008 10:03 AM
|
|
|
|
|
Russell' wrote: any tip?
Perhaps you should use a Source Control program and share the source files into both projects.
This does not account for the differences between the compiler support for C++. I don't know how you plan to deal with that but there is a lot of stuff available in VC2008 that is not in VC6. I highly recommend retiring VC6.
led mike
|
|
|
|
|
Perhaps you are right, but the problem doesn't seems a problem regarding the compiler version: simply seems that every version of visual studio doesn't like that you put the source files out of the default folder.
As I told before, the project are correctly compiled with every compilers (I tested it)...the problem comes when I try to use the same phisical files, this is necessary for me to go on this multiplatform develope.
thanks
Russell
|
|
|
|
|
I don't know for sure but it does sound like having separate projects and folder structures using Source Control to share the code files would be a simple solution.
led mike
|
|
|
|
|
led mike wrote: ...having separate projects and folder structures using Source Control to share the code files would be a simple solution.
I agree.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Russell' wrote: every version of visual studio doesn't like that you put the source files out of the default folder.
Not true at all!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
That's Perfect!!! then tell me how I can do this (in Vs2005) please.
Because...
I just created a test-project, I moved every .cpp and .h files in a different folder(d:\test\src), of course I delete the links to the old files in the project placing there the new links.
Then compiling I got some errors:
[Of course, you first need to 'clean' the contents of the debug folder, elseway obviously the error doesn't came]
Error 1 d:\test\src\stdafx.cpp 5 error C2859: d:\test\test\test\debug\vc80.pdb is not the pdb file that was used when this precompiled header was created, recreate the precompiled header.
or (if you delete by hand every files in the debug folder):
Error 1 d:\test\src\stdafx.cpp 5 fatal error C1083: Cannot open precompiled header file: 'Debug\test.pch': No such file or directory
Please let me know
Russell
|
|
|
|
|
The first one - the pdb file - is easy. If clean doesn't
remove it, delete it by hand. That file probably has full
paths to source files so attached debuggers can magically find the
corresponding source code. It has to be regenerated for the
new source locations.
The PCH is a little trickier. After moving your source files
and re-adding them to the project in their new location:
1) From the solution explorer, right click on the project and choose
properties.
2) Navigate to the C/C++ Precompiled Headers section.
Typical setting should be
Use Precompiled Header (/Yu)
StdAfx.h
$(IntDir)\$(TargetName).pch
3) With the properties window still open, click on the
stdafx.cpp file in the solution explorer. The properties
window will change to show that individual file's settings.
Change the Create/Use Precompiled Header setting to create.
The settings should look like this.
Create Precompiled Header (/Yc)
StdAfx.h
$(IntDir)\$(TargetName).pch
That should be all you have to do.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
very helpfull,
I found also that StdAfx.h and StdAfx.cpp are the main problem when moving a project, maybe they can be copied, not moved, also because different with different compiler version.
thank you, now the problem is solved
Russell
|
|
|
|
|
Russell' wrote: I found also that StdAfx.h and StdAfx.cpp are the main problem when moving a project,
They're only a problem because if you use precompiled headers,
and those are the files that implement the precompiled headers,
then their compile settings need to be set properly.
Without the special PCH settings, they are just source files like
any others
You actually don't have to use those files - you are free to use precompiled
headers through any named source file, or not use precompiled headers at all.
It's the compiler settings that make the difference.
Russell' wrote: now the problem is solved
Cool!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have several projects shared between VC6 and VC8. The solution I use is after opening the solution in VS 2005, go to the properties of each project and change the "Output Directory" and "Intermediate Directory" to something like Debug8 (for debug builds obviously.)
This causes problems with .ncb files, but there's no reason to be actually editing both versions of the project at the same time. Despite the pain, I tend to edit in VC6 since that's what most the releases are in (we deploy to embedded devices which only have the VC6 runtimes.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Thank you, that was my 'temporary' solution...I'm searching for something more 'clean', because place all the project files in the same folders is not good.
Elseway I'll continue to create VC6 projects and update they to Vc8, as before, as you suggest.
thanks
Russell
|
|
|
|
|
Hi to all.
I'm writing an app in which I wont to notify the user about optical media being inserted or removed from drive!
I did some research on web and found this WM. I included proper .h files but I cant get that message for handling it (I don't see it in my main dialog messages).
I founded article "Intercept the insertion/removal of a CD/DVD" by shaman74 (http://www.codeproject.com/KB/system/Message_Spy.aspx[^]). Is this is the only way (don't quite understand all this), no simple ON_WM...
Thanks in advance.
|
|
|
|
|
Read this[^] and this[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
You could also read the most AWESOME article on codeproject, but the most humble and extraordinary author EVER! (laying it on thick enough yet?)
http://www.codeproject.com/KB/system/Drive_Detect.aspx[^]
Just checked, and it does work detecting CDs going in / out, as well as usb drives being added in like origianlly intended.
Iain.
|
|
|
|
|
Hello all..
I'm trying to make window with specific requirement.. But that's not my issue. It's related to RegisterClassEx and CreateWindowEx.. Both actually fails.. I've no idea why.. I put GetLastError on both.
After RegisterClassEx it shows Error 6 which means "The handle is invalid."
After CreateWindowEx it shows Error 203 which means "The system could not find the environment option that was entered."
Here's code snippet.. Please take a look.
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd ;
MSG msg ;
WNDCLASSEX wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) CreateSolidBrush(RGB(255,255,255));
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = "WndProc";
DWORD eRR = GetLastError();
if (!RegisterClassEx (&wndclass))
{
MessageBox (NULL, "Registration Fails","Error", MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindowEx(WS_EX_TOOLWINDOW |WS_EX_LAYERED| WS_EX_APPWINDOW,
"WndProc",
NULL,
WS_POPUP,
10,
10,
100,
100,
NULL,
NULL,
hInstance,
NULL) ;
DWORD eRR1 = GetLastError();
ShowWindow (hwnd, iCmdShow) ;
SetLayeredWindowAttributes(hwnd, RGB(255,255,255), 255, LWA_COLORKEY|LWA_ALPHA);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
It also doesn't get into message loop..
Thanks..
|
|
|
|
|
Actually you're calling GetLastError before RegisterClassEx fails.
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]
|
|
|
|
|
Sorry.. My mistake...If i do something like this..
if (!RegisterClassEx (&wndclass))
{
DWORD eRR = GetLastError();
MessageBox (NULL, "Registration Fails","Error", MB_ICONERROR) ;
return 0 ;
}
i get Error 87.. which says "The parameter is incorrect".. I added
wndclass.cbSize = sizeof(WNDCLASSEX);
but no success...
And if i use WNDCLASS instead of WNDCLASSEX with RegisterClass it can skip registering the class and move to creating the window and then it gives error message 203....
|
|
|
|