|
|
The toolbar you can remove when you are creating your SDI application, you'll find an option, to create or not to create the tool bar there.
To remove menu, you have to override CFrameWnd::LoadFrame() of your Frame window and place a code inside it, like this:
BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext)
{
BOOL bRetVal = CFrameWnd::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext);
if(bRetVal){
GetMenu()->DestroyMenu();
SetMenu(NULL);
}
return bRetVal;
}
Philip Patrick
"Two beer or not two beer?" <shakesbeer>
Web-site: www.saintopatrick.com
|
|
|
|
|
I'm working on a small program with two list controls declared as
<br />
CListCtrl List1, List2;<br />
These are public member variables of CListTestDlg .
The effect I want is for the contents of List2 to change depending on which row was clicked in List1. I have created a handler for the WM_NOTIFY message to handle the NM_CLICK message.
<br />
BOOL CListTestDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) <br />
{<br />
LV_DISPINFO* lvDispInfo = (LV_DISPINFO*) lParam;<br />
CEdit* pEdit;<br />
<br />
switch (lvDispInfo->hdr.code)<br />
{<br />
case LVN_BEGINLABELEDIT:
pEdit = List1.GetEditControl();<br />
break;<br />
case LVN_ENDLABELEDIT:<br />
if ((lvDispInfo->item.pszText != NULL) && (lvDispInfo->item.iItem != -1))<br />
{<br />
List1.SetItemText(lvDispInfo->item.iItem, 0, lvDispInfo->item.pszText);<br />
}<br />
break;<br />
case NM_CLICK:<br />
char text[11];<br />
int i;<br />
<br />
while ((List2.GetItemCount() > 0) && (lvDispInfo->item.iItem != -1))<br />
List2.DeleteItem(0);<br />
List1.GetItemText(lvDispInfo->item.iItem, 2, text, 10);<br />
i = atoi(text);<br />
while (i-- > 0)<br />
{<br />
List1.GetItemText(lvDispInfo->item.iItem, 0, text, 10);<br />
List2.InsertItem(lvDispInfo->item.iItem, text);<br />
}<br />
break;<br />
}<br />
}<br />
The problem I have is that for the NM_CLICK part of the switch statement, lvDispInfo->item.iItem is always zero, regardless of which row is clicked on. However, if I use lvDispInfo->item.mask instead of lvDispInfo->item.iItem things work as I would like.
lvDispInfo->item.iItem appears to be set correctly when dealing with LVN_BEGINLABELEDIT and LVN_ENDLABELEDIT parts are processed.
Please tell me what am I missing?
Paresh Solanki
A Completly Random Ordering Never Yields Meaning
|
|
|
|
|
Are you programming for WinCE?
If not, so here is your problem. The structure LV_DISPINFO is defined and working ONLY in WinCE. In Win32 you have to cast your lParam to LPNMITEMACTIVATE and you will get the item index in iItem member of this struct. Or -1 if no item was selected
Philip Patrick
"Two beer or not two beer?" <shakesbeer>
Web-site: www.saintopatrick.com
|
|
|
|
|
Thanks
I had tried NMLVDISPINFO, but that gave the same results as LV_DISPINFO, couldn't see LPNMITEMACTIVATE on MSDN, but it does what I want.
Paresh Solanki
A Completly Random Ordering Never Yields Meaning
|
|
|
|
|
Yep, sorry, look for NMITEMACTIVATE in MSDN.
LPNMITEMACTIVATE is just a pointer to it
Philip Patrick
"Two beer or not two beer?" <shakesbeer>
Web-site: www.saintopatrick.com
|
|
|
|
|
I am using fragments of code from Microsoft OneInstance sample. When application starts and it founds other instance window, it activates it using next code:
pWndPrev = CWnd::FindWindow(lpszUniqueClass,NULL);
if ( pWndPrev )
{
pWndChild = pWndPrev->GetLastActivePopup();
if (pWndPrev->IsIconic())
pWndPrev->ShowWindow(SW_RESTORE);
pWndChild->SetForegroundWindow();
}
In Windows XP, if pWndPrev is minimized, it is not restored. This code works fine in all previous Windows versions. What changes should be done in this code to work properly in XP ?
|
|
|
|
|
Hi -
I also would love to find a code solution to your problem, but I think it's a registry tweak, which requires a re-login after changing.
HKEY_CURRENT_USER\Control Panel\Desktop
set ForegroundLockTimeout = 0 (DWORD)
set ForegroundFlashCount = 0 (DWORD)
A short article on this at:
http://www.windows2000faq.com/Articles/Index.cfm?ArticleID=15978
If you do find a code solution, please post to this thread.
|
|
|
|
|
|
How can I prevent a user from accessing my ISAPI extension directly from his browser?
I have an ISAPI extension that can be accessed by the URL - <nobr>[http://www.mysite.com/scripts/myisapi.dll?query=value]
I access the extension from an asp page through a form submit request. Now my problem is that anybody smart enough to decipher the url and the query string that needs to be provided to the extension can access it successfully. I would want to prevent this access. How can I go about achieving this?
|
|
|
|
|
Hi,
I can't think of a simple way to do this, but you could modify you ASP code to add an application-specific HTTP header field to the request (I think - I don't know ASP real well) and check for that header in your ISAPI extension. A user could potentially write their own code to include that header, but it would at least prevent someone executing the ISAPI from their browser.
Another possibility is the HTTP header HTTP_QUERY_REFERER which is not always provided, but would show the URL that linked to the ISAPI extension. You'll just need to make sure that the URL matches your ASP page.
Hope this helps.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
thanks derek !
I have considered your advice. But the methods suggested above are not void of loopholes. Http headers are prone to tampering and URL addresses can be spoofed.
I have been looking at the method by which asp pages are prevented from malicious access by the use of session ids. I am talking about the session ids created by the ASP engine. But I have no idea of how to access the same session id in my extension. I want to obtain the session id from the asp engine directly from my extension.
Is this possible?
|
|
|
|
|
Hi,
As far as I know, there is no way to get the session id outside of ASP (which is not to say that there isn't a way!).
If you are attempting to prevent malicious use of the ISAPI extension, would it be possible to encrypt the query string before passing it to the ISAPI DLL? If the ISAPI DLL reads the query string and can't decode it, then assume it comes from a spurious source and do something accordingly. We use a similar system to this (although our encryption is done by a client-side app, rather than an ASP page).
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Hi,
I need to retrieve the logical coordinates of the printer, I tried to use this:
CSize Test;
Test.cx = pDC->GetDeviceCaps(HORZRES);
Test.cy = pDC->GetDeviceCaps(VERTRES);
The I use that logical coordinates to print a metafile, but seems that the coordinates are not the right ones ( they are small), how can I retrieve that logical size ?, Thanks, Bye !
Braulio
|
|
|
|
|
I think your problem is in the conversion. Metafile needs coordinates in .01 millimeter units.
Try something like this:
RECT rc;
rc.top = rc.left = 0;
int iWidthMM = pDC->GetDeviceCaps(HORZSIZE);
int iHeightMM = pDC->GetDeviceCaps(VERTSIZE);
int iWidthPels = pDC->GetDeviceCaps(HORZRES);
int iHeightPels = pDC->GetDeviceCaps(VERTRES);
rc.right = (nWidth * iWidthMM * 100)/iWidthPels;
rc.bottom = (nHeight * iHeightMM * 100)/iHeightPels;
HDC hMetaDC = CreateEnhMetaFile(pDC->GetSafeHdc(),_T("C:\\Temp\\Image.emf"), &rc, _T("Your Description\0Image\0\0"));
- God bless the World
|
|
|
|
|
Hi,
I would like to rotate 90º a metafile, in order to make fit two pages in one if the user chooses to print in A3 format. How can I rotate a metafile ?.
Thanks, Bye !
Braulio
|
|
|
|
|
how to make the pocketPC become fullscreen (including hide the taskbar and menubar) in eVC (embeded visual c++ 3.0)
pls answer it as soon as posible, T.Q.!
|
|
|
|
|
Try article "Q266244" in MSDN.
HOWTO: Create Full-Screen Applications for the PocketPC
Normski. - Professional Windows Programmer
|
|
|
|
|
The Following code works fine except for the black edges that are displayed in the Transparent Image. How can I get rid of that???
COLORREF m_crWhite = RGB(255,255,255);
COLORREF m_crBlack = RGB(0,0,0);
//pdc is the Screen Dc
COLORREF crOldBack = pDC->SetBkColor(m_crWhite);
COLORREF crOldText = pDC->SetTextColor(m_crBlack);
COLORREF crOldBkMode = pDC->SetBkMode(TRANSPARENT);
//The Following 2 lines gives me image information.
int nImageWidth = m_pImageInfoData->bmpInfo.bmiHeader.biWidth;
int nImageHeight = m_pImageInfoData->bmpInfo.bmiHeader.biHeight;
CBitmap BmpMask;
BmpMask.CreateBitmap( nImageWidth, nImageHeight, 1, 1, NULL);
CDC hdcSrc, hdcDst;
hdcSrc.CreateCompatibleDC(pDC);
hdcDst.CreateCompatibleDC(pDC);
CBitmap BmpSource;
BmpSource.CreateCompatibleBitmap(pDC,nImageWidth,nImageHeight);
CBitmap* hbmSrcT = (CBitmap*) hdcSrc.SelectObject(&BmpSource);
CBitmap* hbmDstT = (CBitmap*) hdcDst.SelectObject(&BmpMask);
StretchDIBits(hdcSrc.GetSafeHdc(),
0, 0, nImageWidth, nImageHeight,
0, 0, nImageWidth, nImageHeight,
m_pImageInfoData->pszData,
&(m_pImageInfoData->bmpInfo),
DIB_RGB_COLORS, SRCCOPY);
COLORREF clrSaveBk = hdcSrc.SetBkColor(crColor);
hdcDst.BitBlt(0,0,nImageWidth, nImageHeight, &hdcSrc,0,0,SRCCOPY);
COLORREF clrSaveDstText = hdcSrc.SetTextColor(RGB(255,255,255));
hdcSrc.SetBkColor(RGB(0,0,0));
hdcSrc.BitBlt(0,0,nImageWidth, nImageHeight, &hdcDst,0,0,SRCAND);
hdcDst.SetTextColor(clrSaveDstText) ;
hdcSrc.SetBkColor(clrSaveBk);
pDC->StretchBlt( nLeft, nTop, nWidth, nHeight, &hdcDst,
0, 0, nImageWidth,nImageHeight,SRCAND);
pDC->StretchBlt( nLeft, nTop, nWidth, nHeight, &hdcSrc,
0, 0,nImageWidth,nImageHeight,SRCPAINT);
hdcSrc.SelectObject(hbmSrcT);
hdcDst.SelectObject(hbmDstT);
hdcSrc.DeleteDC();
hdcDst.DeleteDC();
pDC->SetBkMode(crOldBkMode);
pDC->SetTextColor(crOldText);
pDC->SetBkColor(crOldBack);
|
|
|
|
|
Change your image so the outside square is the mask color. Or do you mean black edges around your image ? Either way, it's obviously a problem with the mask. You can use GDI+ to draw transparent images and specify a *range* for red, green and blue to be transparent. Otherwise you could iterate through the bits and change any color within a range to be the mask color.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I'm not using MFC, and I'm storing bitmaps inside my own button classes, which encapsulate the HWND of the button. If I respond to the WM_DRAWITEM message, and draw my buttons, they flicker like crazy if the window is being resized ( and they are moved ). The ones that stay put also flicker as they are redrawn.
I've been trying to get a wndproc happening to subclass the buttons, but that seems not to want to work. Does anyone have any other suggestions ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Whenever your window is being resized, your main window is receiving a WM_ERASEBKGND message. This message by default erases all the controls on the window which then need to be redrawn. This is bad for flicker. One was around this would be to use the following routine to only fill in that windows area by excluding the areas of the controls on the window so they are not erased:
int dont_erase_indexes[] =
{
IDC_DPAS_LAMP,
IDC_INSTRUMENT_TYPE,
IDC_LABEL1,
IDC_LABEL2,
IDC_DESTINATION,
IDC_CURRENT_STATUS,
IDC_LOG,
IDC_GRAPH,
IDC_DOWNLOAD_STATUS,
IDC_DOWNLOAD_PROGRESS,
ID_AUTO_LOAD,
IDC_UPLOAD_ASSAYS,
IDC_AUTO_UPLOAD,
IDC_BROWSE_FOR_FOLDER
} ;
BOOL CYourWindow::OnEraseBkgnd(CDC* pDC)
{
static int dont_erase_indexes[] =
{
IDC_DPAS_LAMP,
IDC_INSTRUMENT_TYPE,
IDC_LABEL1,
IDC_LABEL2,
IDC_DESTINATION,
IDC_CURRENT_STATUS,
IDC_LOG,
IDC_GRAPH,
IDC_DOWNLOAD_STATUS,
IDC_DOWNLOAD_PROGRESS,
ID_AUTO_LOAD,
IDC_UPLOAD_ASSAYS,
IDC_AUTO_UPLOAD,
IDC_BROWSE_FOR_FOLDER
} ;
CRect clip ;
pDC->SaveDC() ;
for (int i = 0 ; i < sizeof(dont_erase_indexes) / sizeof(int) ; i++)
{
GetDlgItem(dont_erase_indexes[i])->GetWindowRect(&clip);
ScreenToClient(&clip);
pDC->ExcludeClipRect(&clip);
}
pDC->GetClipBox(&clip);
pDC->FillSolidRect(clip, GetSysColor(COLOR_BTNFACE));
pDC->RestoreDC(-1) ;
return FALSE;
}
Hope this helps out
Roger Bin Allen
|
|
|
|
|
Hey, cool. I did not know about this stuff, thank you *very* much.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Hello fellow CPians. Happy New Year!
On my break from school, I thought I'd torture myself be reading Charles Petzold's Programming Windows. It's actually been a great read until now.
One of the sample programs declares a PMSG variable. The code goes on to allocate enough memory to store the appropriate amount of space using;
pmsg = malloc (cLinesMax * sizeof (MSG));
This code does not compile is VC6, SP5. I get the following error;
error C2440: '=' : cannot convert from 'void *' to 'struct tagMSG *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
I've tried casting the return value to PMSG which solve the compile problem but the program bombs! I'm in way over my head on this one...
Any help that anyone can provide is greatly appreciated.
Sorry for the size of the post, but here's the complete code.
#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT("KeyView1");
HWND hwnd;
MSG msg;
WNDCLASS 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.lpszMenuName = NULL;
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszClassName = szAppName;
if (!RegisterClass (&wndclass))
{
MessageBox(NULL, TEXT("This application requires WinNT to run."),
szAppName, MB_ICONERROR);
return 0;
}
hwnd = CreateWindow(szAppName, TEXT("Keyboard Message Viewer #1"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
static int cxClientMax, cyClientMax;
static int cxClient, cyClient;
static int cxChar, cyChar;
static int cLinesMax, cLines;
static PMSG pmsg;
static RECT rectScroll;
static TCHAR szTop[] = TEXT("Message Key Char ")
TEXT(" Repeat Scan Ext ALT Prev Tran");
static TCHAR szUnd[] = TEXT("------- --- ---- ")
TEXT(" ------ ---- --- --- ---- ----");
static TCHAR* szFormat[2] = {
TEXT("%-13s %3d %-15s%c%6u %4d %3s %3s %4s %4s"),
TEXT("%-13s 0x%04x%1s%c %6u %4d %3s %3s %4s %4s") };
static TCHAR* szYes = TEXT("Yes");
static TCHAR* szNo = TEXT("No");
static TCHAR* szDown = TEXT("Down");
static TCHAR* szUp = TEXT("Up");
static TCHAR* szMessage[] = {TEXT("WM_KEYDOWN"), TEXT("WM_KEYUP"),
TEXT("WM_CHAR"), TEXT("WM_DEADCHAR"),
TEXT("WM_SYSKEYDOWN"), TEXT("WM_SYSKEYUP"),
TEXT("WM_SYSCHAR"), TEXT("WM_SYSDEADCHAR") };
HDC hdc;
int i, iType;
PAINTSTRUCT ps;
TCHAR szBuffer[128], szKeyName[32];
TEXTMETRIC tm;
switch (message)
{
case WM_CREATE:
case WM_DISPLAYCHANGE:
cxClientMax = GetSystemMetrics(SM_CXMAXIMIZED);
cyClientMax = GetSystemMetrics(SM_CYMAXIMIZED);
hdc = GetDC(hwnd);
SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
GetTextMetrics(hdc, &tm);
cxChar = tm.tmAveCharWidth;
cyChar = tm.tmHeight;
ReleaseDC(hwnd, hdc);
if (pmsg)
free (pmsg);
cLinesMax = cyClientMax / cyChar;
pmsg = malloc (cLinesMax * sizeof (MSG));
cLines = 0;
case WM_SIZE:
if (message == WM_SIZE)
{
cxClient = LOWORD(lParam);
cyClient = HIWORD(lParam);
}
rectScroll.left = 0;
rectScroll.right = cxClient;
rectScroll.top = cyChar;
rectScroll.bottom = cyChar * (cyClient / cyChar);
InvalidateRect(hwnd, NULL, TRUE);
return 0;
case WM_KEYDOWN:
case WM_KEYUP:
case WM_CHAR:
case WM_DEADCHAR:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
case WM_SYSCHAR:
case WM_SYSDEADCHAR:
for (i = cLinesMax - 1; i > 0; i--)
{
pmsg[i] = pmsg[i - 1];
}
pmsg[0].hwnd = hwnd;
pmsg[0].message = message;
pmsg[0].wParam = wParam;
pmsg[0].lParam = lParam;
cLines = min(cLines + 1, cLinesMax);
ScrollWindow(hwnd, 0, -cyChar, &rectScroll, &rectScroll);
break;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
SetBkMode(hdc, TRANSPARENT);
TextOut(hdc, 0, 0, szTop, lstrlen(szTop));
TextOut(hdc, 0, 10, szUnd, lstrlen(szUnd));
for (i = 0; i < min(cLines, cyClient / cyChar - 1); i++)
{
iType = pmsg[i].message == WM_CHAR ||
pmsg[i].message == WM_SYSCHAR ||
pmsg[i].message == WM_DEADCHAR ||
pmsg[i].message == WM_SYSDEADCHAR;
GetKeyNameText(pmsg[i].lParam, szKeyName, sizeof(szKeyName) / sizeof(TCHAR));
TextOut(hdc, 0, (cyClient / cyChar - 1 - i) * cyChar, szBuffer,
wsprintf(szBuffer, szFormat[iType],
szMessage[pmsg[i].message - WM_KEYFIRST],
(PSTR) (iType ? TEXT(" ") : szKeyName),
(TCHAR) (iType ? pmsg[i].wParam : ' '),
LOWORD (pmsg[i].lParam),
HIWORD (pmsg[i].lParam) & 0xFF,
0x10000000 & pmsg[i].lParam ? szYes : szNo,
0x20000000 & pmsg[i].lParam ? szYes : szNo,
0x40000000 & pmsg[i].lParam ? szDown : szUp,
0x80000000 & pmsg[i].lParam ? szUp : szDown));
}
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
Paul Lyons
Do not go where the path may lead, go instead where there is no path and leave a trail.
- Ralph Waldo Emerson
|
|
|
|
|
I dunno what are you trying to say, man. I didn't read all the code, get bored.
But. The malloc() function returns void* , it is known and it is ok. You should cast the return value to whatever you want like this:
pmsg = (MSG*)malloc (cLinesMax * sizeof (MSG));
That's all. No buzzz It will elliminate the error you got
Philip Patrick
"Two beer or not two beer?" <shakesbeer>
Web-site: www.saintopatrick.com
|
|
|
|
|