|
hai nelek.
good question and thanks for your response.
Nelek wrote: is the first control appearing when back to first position?
no it is not.
any way, i got it solved by using Invalidate(); after scrollwindowex function.
but i have few more doubts.
like, for example, i want to display 40 students' data on the screen.
the headings will be
ID NAME AGE CLASS ADDRESS
and follows the 40 rows of 5 textboxes
now, if i scroll, up or down, the headings (which i use as static boxe(s)) should not scroll up or down ,and also the buttons save saveas cancel on the down of the page.
i mean, only the textboxes should move.
any clues?
NOTE: student is for an example.
|
|
|
|
|
The first problem was so because controls out the frame are invisible. For that reaason the invalidate is needed to repaint the actual visible portion of screen.
For the second... I had a similar problem in my project. I got a completely different solution.
You are whishing to fill the controls with "static" datas and scrolling the controls. I made it by fixing the controls and scrolling the datas.
If you are interested in my solution I can post you some snippets, but I don't now do it because it can be large :P
EDIT: I can imagine a way, but not sure if it'll be possible. Can you set the scroll to a concrete region? I mean divide your dialog in three parts, where the first and the third are fixed, and setting the scroll only in the central one.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Nelek wrote: The first problem was so because controls out the frame are invisible. For that reaason the invalidate is needed to repaint the actual visible portion of screen.
thanks for the explanation.
Nelek wrote: I made it by fixing the controls and scrolling the datas.
nice idea, but i can use it only, if there is no other go.
and i shall try that logic myself. if i fail, then i will ask your code snippet. thanks for your response.
Nelek wrote: I can imagine a way, but not sure if it'll be possible. Can you set the scroll to a concrete region? I mean divide your dialog in three parts, where the first and the third are fixed, and setting the scroll only in the central one.
this is what exactly now i was trying to do.
i shall update you, if it is successful.
i have one more idea.
for every scroll, weather up or down, i can move the header and footer to the same old positions.this will be my next try.
thanks a lot for your continuous support.
|
|
|
|
|
"for every scroll, weather up or down, i can move the header and footer to the same old positions.this will be my next try."
Consider difference between screen / workspace coordinates.
I have a CSCrollView as main view, and the bitmaps representing objects are placed according to scroll position. But there is a moment that I want to have a label always visible. I do it just so easy as:
CClientDC dc(this);
CRect rectWnd;
CString szOnline = "ONLINE";
CPoint cpPoint;
CFont fontLabels;
fontLabels.CreatePointFont (640, "MS Sans Serif");
GetWindowRect (&rectWnd);
cpPoint.x = ((rectWnd.Width () - 300) / 2);
cpPoint.y = ((rectWnd.Height () - 100) / 2);
dc.SelectObject (&fontLabels);
dc.SetBkColor (RGB (0, 255, 0));
dc.TextOut (cpPoint.x, cpPoint.y, szOnline, szOnline.GetLength ());
I have the label always visible and centered on the screen. You can do something similar for the "fixed" controls.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
thanks for the logic.
i shall implement it.
|
|
|
|
|
Hello Friends !!!!
Can anybody tell me how to know that the mouse has left the Tray Icon. I mean which message is sent when mouse leave the Tray Icon..
I am devloping the application in which I am showing context menu when someone do the Right mouse click on the Tray Icon and the showing dialog box when mouse is over the Tray Icon. I want to hide the dialog when mouse leaves the Tray Icon and also want. But dont know how to do it.
If anydody knows or have any Idea please tell me.
|
|
|
|
|
GauranG33 wrote: I want to hide the dialog when mouse leaves the Tray Icon...
How are you detecting that the mouse has entered the taskbar notification area?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Follwing is the Code I am using to know whether the mouse is on the Tray Icon or not. If its on the Tray Icon I am showing the Dialog Box. But I want to Hide it when It leave the Tray Icon.
void PutInTaskBar(HWND hWnd)
{
...
...
nfd.uCallbackMessage = WM_TASKMSG;
Shell_NotifyIcon(NIM_ADD,&nfd);
}
LRESULT CALLBACK MyDialogProc( ... )
{
switch(message)
{
case WM_TASKMSG:
if(lParam == WM_MOUSEMOVE)
{
ShowWindow(hWndDlg,TRUE);
}
}
}
|
|
|
|
|
Hi,
I am using ListView with 4 coloumn to list some strings. I want to add bitmap at firstcolumn with string. I have written some code but not working please help:
<br />
CListCtrl &LstPtr=GetListCtrl();<br />
CBitmap bitmap;<br />
ImageList.Create(16, 16, ILC_COLOR32|ILC_MASK,9,0);<br />
bitmap.LoadBitmap(IDB_TREE);
ImageList.Add(&bitmap, 0xFFFFFF);<br />
LstPtr.SetImageList(&ImageList,TVSIL_NORMAL);<br />
bitmap.DeleteObject();<br />
<br />
<br />
LRESULT CListViewRight::OnMsgAddStringToListCtrl(WPARAM wParam,LPARAM lParam)<br />
{<br />
CListCtrl &LstPtr=GetListCtrl();<br />
int nItem=(int)lParam;<br />
GetListViewLineNumber(nItem);<br />
<br />
switch(nItem)<br />
{<br />
case 1:<br />
<br />
LstPtr.InsertItem(m_nListViewLineNumber,(LPCTSTR(wParam)),0);<br />
break;<br />
<br />
case 2:<br />
LstPtr.SetItemText(m_nListViewLineNumber,1,(LPCTSTR(wParam)));<br />
break;<br />
<br />
case 3:<br />
LstPtr.SetItemText(m_nListViewLineNumber,2,(LPCTSTR(wParam)));<br />
break;<br />
<br />
case 4:<br />
LstPtr.SetItemText(m_nListViewLineNumber,3,(LPCTSTR(wParam)));<br />
break;<br />
}<br />
return TRUE;<br />
}<br />
<br />
|
|
|
|
|
|
hai friends,
iam using pretranslatemessage to handle the keys in my dialog.
now my problem is, i want to do some action, on pressing ctrl+arrow key.
how can i achieve this?
if any more details are required, then i can provide.
thanks in advance for help.
|
|
|
|
|
Hi,
to check if a control key is pressed with the wished key,
you can test it this way :
if(GetKeyState(VK_CONTROL)<0 && pMsg->WPARAM == VK_DOWN) {
// CTRL + DOWN
}
I hope it helps
|
|
|
|
|
wow,
it works.
GetKeyState() is the function, which i wanted exactly.
thank you.
|
|
|
|
|
You check for VK_CONTROL in WM_KEYDOWN/WM_KEYUP and set an internal flag.
Depending on that state you can then react to VK_LEFT , VK_UP , VK_RIGHT and VK_DOWN .
A lot like this:
void CMyListBase::OnKeyDown(UINT nChar)
{
switch (nChar)
case VK_CONTROL:
if (true)
m_bControl = true;
else
m_pListCtrl->Default();
break;
case VK_LEFT:
if( m_bControl)
HandleLCTRLLeft();
break;
}
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
thanks for your reply.
your logic is also good and seems to work.
|
|
|
|
|
Hello,
does anyone have some expierience with stdext::hashmap with VS2005?
Is this container ready for use, is it sure for use?
I have some problems in my program with them, the find function does not find items in map
and i know that they are inside!
Thanks for Answers!
termal
|
|
|
|
|
For me, stdext::hashmap from VC.NET 2005 does work flawlessly.
Can you give some sort of a minimal testprogram showing your problems?
-- modified at 7:32 Monday 22nd October, 2007
Stupid typo fixed.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Hello,
thanks for answer, here is a sample code:
class CMyClass
{
CString csName;
CString csVName;
int iName;
}
typedef LPCTSTR MyString;
struct str_compare
{
bool operator()(const MyString& lpStr1, const MyString& lpStr2)
{
return wcscmp(lpStr1, lpStr2) == 0;
}
};
CMyClass myClass;
myClass.csName = L"John";
myClass.csVName = L"Do";
myClass.iAge = 20;
hash_map<MyString, CMyClass>myhashmap;
myhashmap.insert(L"John", myClass);
hash_map<MyString, CMyClass, hash_compare<MyString, str_compare>>::iterator testiterator;
testiterator = myhashmap.find(L"John");
if(myhashmap.end() != testiterator)
AfxMessageBox("Item found");
else
AfxMessageBox("Item not found");
To add items and iterate trough my hash_map is no problem, with iterate i mean if i use any loop
and print all items out!
I have to say that project is in unicode and multithreaded, that means that many threads
add items and read them from a hash_map!
So, each thread search in a hash_map to see if item is already inside, if not, add a new item,
if the item is already inside, update them content!
Thanks for your time!
Regards
termal
|
|
|
|
|
Your code does not even compile!
Anyway, are you positivly sure you want a hash_map here?
You do not have a good hash at hand, it seems. A normal map would be smarter, I think.
Anyway,
typedefs can help you sort the myriads of < and >.
str_compare should do what exactly? Define a strict ordering between the items given. Look how less<> works and define your comparer accordingly.
Here, I have used the standard less comparer.
And you are right, it doesn't work when mixing CString and LPCTSTR in insert and find . My version works if LPCTSTR or CString are used consistently.
#include "stdafx.h"
#include <hash_map>
#include "iostream"
#include "windows.h"
#include "atlstr.h"
class CMyClass
{
public:
CString csName;
CString csVName;
int iAge;
};
int _tmain(int argc, _TCHAR* argv[])
{
CMyClass instance1;
instance1.csVName = _T("John-Boy");
instance1.csName = _T("Walton");
instance1.iAge = 20;
CMyClass instance2;
instance2.csVName = _T("Jim-Bob");
instance2.csName = _T("Walton");
instance2.iAge = 16;
typedef stdext::hash_map<LPCTSTR, CMyClass, stdext::hash_compare<LPCTSTR, std::less<LPCTSTR> > > MyHashMapT;
typedef MyHashMapT::iterator MyHashMapIt;
MyHashMapT myhashmap;
std::pair<MyHashMapIt, bool> result = myhashmap.insert( MyHashMapT::value_type( _T("John-Boy"), instance1));
result = myhashmap.insert( MyHashMapT::value_type( _T("Jim-Bob"), instance2));
MyHashMapIt testiterator = myhashmap.find( _T("John-Boy"));
if( myhashmap.end() != testiterator)
std::wcout << _T("Item found") << std::endl;
else
std::wcout << _T("Item not found") << std::endl;
return system("pause");
}
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Hello,
thank you very much for your help, that helps me i hope to solve my problem!
Can you write this line again:
typedef stdext::hash_map > > MyHashMapT;
I can see that i isert items in other way as in your sample, maybe is that the problem:
My insert:
myhashmap.insert(L"John-Boy", instance2);
Your insert:
myhashmap.insert(MyHashMapT::value_type( _T("John-Boy"), instance1));
I dont use ::value_type, i try now with your codesample, and make typedefs!!
Regards
termal
|
|
|
|
|
The line you were missing:
typedef stdext::hash_map< LPCTSTR, CMyClass, stdext::hash_compare< LPCTSTR, std::less<LPCTSTR> > > MyHashMapT;
I hate how the pre-tag is not able to take its content literally!
The value_type should just be a std::pair made of key-type and value-type. It might actually be clearer to write:
std::pair<MyHashMapIt, bool> result = myhashmap.insert( std::pair< LPCTSTR, CMyClass>( _T("John-Boy"), instance1));
result = myhashmap.insert( std::pair< LPCTSTR, CMyClass>( _T("Jim-Bob"), instance2));
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Hello,
do you have a little sample from your work, how you use the hash_map,
i think im going crazy now with my map!
I can't find intems in my map!
What kind of datatype u use for a key?
I need any string type that is compatible with my hash_map and VS8 to set as key value!!
With best regards!
termal
|
|
|
|
|
I use int as a key.
Why do you desperately need a hash_map and not a normal std::map ?
For any practical purposes, the speed will not be too much different. If you worry about speed but do not get your work done you are doing premature optimization anyways.
You might need to come up with a hashing-function for your string and provide that to your hash_map. But I have never done that myself.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
I have developed a Tool . This tool basically check for latest release in the source location and automatically starts copying the release folder to destination. For copying i have used Robocopy software. I have written the code in Win32 console application C++. The problem is the robocopy software should be present in C drive ie (it is hard-coded in code).
How can i attach Robocopy exe to main appliation Exe , such that whenever you invoke the application exe , it will search whether robocopy exe is present at that place , if not it will copy the robocopy exe which is embedded in the Application exe to required location.
Is it possible? Do i need to convert from Win32 console application to MFC application?
Thanks,
Ashish
|
|
|
|
|
You can embedd an exe/dll within your application itself as a resource(i recommends MFC & Visual Studio IDE for speed up your development). and later on you can extract and use it. the only problem is total size of your application will grow.
Never Work Hard! - Work Smart!!!
|
|
|
|
|