|
Hi
code is as follows
if((hInst_temp = GetModuleHandle(NULL))==NULL)
{
MessageBox(NULL,"GetModuleHandle error",NULL,MB_OK);
}
if(-1 ==WlxDialogBoxParam(hWlx, hInst_temp,MAKEINTRESOURCE(IDD_DXCAPTURE_DIALOG),NULL, MyCaptureDlgProc, dwInitParam))
{
LPVOID lpMsgBuf;
LPVOID lpDisplayBuf;
DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
lstrlen((LPCTSTR)lpMsgBuf)+lstrlen((LPCTSTR)"gina")) *sizeof(TCHAR));
wsprintf((LPTSTR)lpDisplayBuf,
TEXT("%s failed with error %d: %s"),
"Gina", dw, lpMsgBuf);
MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK);
LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf);
}
error number is 1813( ths specified resource type cannot found in image file)
Manjunath S
GESL
Bangalore
|
|
|
|
|
Just an advise, use pre tags for code, its become readable.
Manjunath S wrote: if(-1 ==WlxDialogBoxParam(hWlx, hInst_temp,MAKEINTRESOURCE(IDD_DXCAPTURE_DIALOG),NULL, MyCaptureDlgProc, dwInitParam))
Is it dll code ?
I'm not sure, but its something related to AfxSetResourcehandle, you need to set it right for calling process.
|
|
|
|
|
Hi,
Thanks for your useful response ...
Now its working fine...
I also made a mistake in dialog procedure
Manjunath S
GESL
Bangalore
|
|
|
|
|
|
Greetings brilliant kind and helpful Code Project types! we the lurkers and lowly rabble thank you!
i am using a dialog box as a front end to a flat file databaseon top of a document view SDI
in the dialog, the user adds data to two edit controls (one rich edit - the other just an edit control)
when the user tabs to either edit control, existing text in the control is selected, and if they begin text entry without clearing the slection, the existing text is deleted
the NO Hide Selection check box in the resources editor only clears the selection when the control loses focus
using EN_SETFOCUS (after changing the on_notify to on_en_setfocus in the message map), a pointer to the control and SelSel(0,0) *Works Great In Debug Configuration*, HOWEVER
the RELEASE configuration gives an Access Violatin exception, even without my pointer and SetSel(0,0), whenever you call oninitdialog when the onsetfocus code is present
the debugger provides error cxx0017 error: symbol "this" not found - and the code displayed is in \mfc\src\appmodul.cpp documented as "export winmain to force linkage to thes module"
I hvae also tried using pointer/setsel in other locations without success
Any Suggestions?
how might I change my program so that it is harder for the user to delete existing text which has unwanted selection upon gaining focus to the edit control using the tab key?
Thanks in advance for your time and consideration
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
lctrncs wrote: how might I change my program so that it is harder for the user to delete existing text which has unwanted selection upon gaining focus to the edit control using the tab key?
When the control receives focus, call its SetSel(0, 0) method.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
lctrncs wrote: when the user tabs to either edit control, existing text in the control is selected
This is the default behaviour of the dialog manager. If this is undesirable you should tell the dialog manager, by subclassing the edit control and handling WM_GETDLGCODE[^] to not return the DLGC_HASSETSEL flag (call the base class procedure and mask it out ie. & ~DLGC_HASSETSEL).
lctrncs wrote: using EN_SETFOCUS (after changing the on_notify to on_en_setfocus in the message map),
How did you go about doing this? Using the IDE or manual edits to the message map? EN_SETFOCUS is sent through a WM_COMMAND message, and not a WM_NOTIFY message. The member function signature for both are different. Not sure if this is the problem though as I think the compiler should complain if you made a mistake.
Edit: Link regarding WM_GETDLGCODE http://blogs.msdn.com/oldnewthing/archive/2003/11/14/55678.aspx[^]
-- modified at 15:19 Thursday 24th August, 2006
|
|
|
|
|
hfry - thanx.
your proposed solution looks feasible, and I will give it a try soon
I will have to understand all this subclassing stuff first...
it looks interesting.
You asked about how I changed on_notify and on_en_setfocus
hfry wrote: How did you go about doing this? Using the IDE or manual edits to the message map?
I based my changes on this url
http://support.microsoft.com/default.aspx?scid=kb;en-us;181664[^]
after making the ON_NOTIFY TO EN_SETFOCUS change to the messagemap associated withthe Visual C++ 5.0 and 6.0 bug discussed in the link
I added my pointer/SetSel(0,0) code to the OnSetFocusTheEditControl function
there were no compiler errors
everything worked fine in debug configuration
however, changing to release configuration caused an access violation - with or without my pointer/SetSel(0,0) code whenever the modified function was present
the Microsoft page about the bug also said that you had to have AfxInitRichedit() in your dialog initinstance and modify the message handlers, but I cannot find any difference in the handlers other than the arguments
variations on these themes were not successful either - still the Access Violation in release config when oninit the dialog
A different link suggested that my pointer might be trying to hit the control before it existed - maybe that is the missing "this"? However, the problem occurs even without my pointer
I tried to use the en_killfocus a while back for something else using the same type of messagemap modifications, and had a similar release configuration exception - which forced me to use a different aproach
I wish I understood what the problem is with the modified on_en_setfocus, or better, how to eliminate it in release config and understand it.
I hope this answers your question.
Thanks again.
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
The handler should look like
void OnSetfocusRichedit1();
instead of
void OnSetfocusRichedit1(NMHDR* pNMHDR, LRESULT* pResult);
Is the first handler what you have?
|
|
|
|
|
I tried both - but I got compiler errors unless I included the LRESULT*pResult argument for the first one.
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
lctrncs wrote: I got compiler errors unless I included the LRESULT*pResult argument for the first one.
That can't be right. What are the compile errors? Having a return value when there isn't supposed to be one would put your stack out of whack. I don't have VC6 (I use VS2003) so the classwizard is fine.
I created a simple MFC dialog app, added a Edit and RichEdit control and have focus handlers for both and I can't duplicate this behaviour.
|
|
|
|
|
Wow.
Thanks for your feedback!
I very much appreciate it.
You seem interested in this from an almost didactic standpoint.
I can appreciate that.
I need to clear the selection on my control so my users do not erase their data.
Perhaps we can collaborate.
What can't be right? Including the LRESULT*pResult?
Let me first say that I used to test ATM network protocol analyzers for HP - and can test many options quickly.
Let me know more about your area of interest - and I will try to assist.
Lets review the possibilities.
I am using Visual C++ 6.0 Standard (copyright 1994-1998) MSCorp.
I used the classwizard to add an EN_SETFOCUS function for either/both a rich edit control or an edit control, then changed the message map as directed by the microsoft bug admission url (see previous message) - and added AfxInitRichEdit(); to my InitInsatnce as directed by the MS URL.
Perhaps this is/can be a baseline?
I will test the options now - good thing I am sleep apnea/narcoletpic/insomniac!
1. does afxinitrichedit end exception if present in initinstance if altered on_en_setfocus code present(not include SetSel) in release?
stand by ...
release config - no onsetfocus -> no access violotion - open dilog box interface to DB on top of document view - no problem
remove comments from altered on_notify->on_en_setfocus map/handler/function - but no pointer/SetSel(0,0) code int onsetfocus function...
PS: dialog box modeless....
->Unhandled exceptoin - access violation = true.
onsetfocus arguments (Lresult *pResult) -> onsetfocus arguments (Lresult *pResult) ->access violation = true
onsetfocus arguments () -> access violation = true
onsetfocus arguments (NMHDR, pNMHDR, Lresult *pResult) -> access violation = true
ADD SetSel(0,0) -> access violation = true
previous post appears incorrect that onsetfocus arguments (Lresult *pResult) ->access violation = false <- false
if setfocus code present - even though compiles in debug p (after) changing on_notify to ON-En-Setfocus - access violation in release config
no possibility appears to function when unaltered, or altered onsetfocus code present in release config (although fixed in debug when onsetfocus arguments (NMHDR, pNMHDR, Lresult *pResult).
A local high end embedded programmer suggested that I might not have allthe libraries I need.
perhaps I should be trying to learn about subclassing
All I want to do is clear a selection when I hit the control...
WHY is this so hard?
I hope this delivers useful info.
Thanks again for your feedback.
sleep awaits...
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
After 10 winks or so, I thought I would run through the cases again to make sure I didn't miss anything.
This time, it appears to work in release config with the following changes to the original code ...
AfxInitRichEdit in the initinstance
alterations to the classwizard's incorrect messagemap from on_notify to on_en_setfocus
alterations to the handler to reflect change in messagemap
including removing all arguments in the handler - and then the function
maybe the key ingredient here was sleep!
I think I go get more.
Thanks for your help!
"For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash
|
|
|
|
|
Hello everyone,
my Prob is not really MFC related I think, but I didnt find a better spot.
So, I have a SDI app, in which I have the normal IDR_MAINFRAME thing and a corresponding icon.
But I also use xp style menus, where I use icons, which are NOT published in the "Resource.h". If do so, the icons dont show up anymore in my contextmenus. But if I dont publish them in the resource.h then my application icon is somehow overwritten. That means the icon shown for my app is the last icon I added for my menus.
Resource.h
<br />
#define IDR_MAINFRAME 24<br />
#define IDI_BROWSER 123<br />
App.rc
<br />
IDR_MAINFRAME ICON res\\app.ico<br />
IDI_BROWSER res\\browser.ico<br />
if I put it like that, then the desktop icon is correct, but my icons dont show in the contextmenus
if I remove the line #define IDI_BROWSER 123, then my menus show the icons, but my app icon is all of a sudden the browser icon, or the last icon I added to the menu icons in the app.rc. I also tried rearanging the order, because it says the lowest number is the programms icons...didnt help. Or did I change orders in the wrong place ?
The mainapp window icon never changes, that is allways the correct app.ico
So my actual question is :
What can I do about that?
How can I manually influence, which icon is shown on the desktop? Where is that set?
Thanks a lot for any small hint!
Best regards $motty
|
|
|
|
|
easy actually. open the resource header and assign a new number to the icons. The icon you want on the desktop should have the lowest number.
|
|
|
|
|
yes, thats what I understand from reading to comments in the app.rc, but thats my prob, I cant assign numbers to the menu icons, so I cant make sure they are lower
internaly they seem to get lower assignments if I DONT give them numbers.
I have been working on a different app for a while, where the desktop icon didnt have a number at all, at least from I saw......
But from review that I think I found the trick......DONT assign a number to any icon and let the NAME (stupid but it works) just be the very first in alphabetic order....
thanks for ur help, it made me figure it out!
|
|
|
|
|
You don't need to open the .rc file. Alongside the resource file there is a header file, usualy called resources.h this has all the #define statements for the items in the resource file. Just find your icon and change the number to 1. i.e.
#define IDI_ICON1 1
or whatever name you decided to give it
|
|
|
|
|
thank you again for thinking about this !
But as soon as I define IDI_ICON1, I cannot use this icon anymore for my officeXP Style contextmenus.
So the solution for my problem was hand opening the app.rc, putting in my icons with
IDI_Icon1 ICON res\\someIcon1.ico
IDI_Icon2 ICON res\\someIcon2.ico
IDI_Icon3 ICON res\\someIcon3.ico
and then using
__IDI_APPICON ICON res\\myApp.ico <---- the "____" is the trick to get it to position #1 (lexicographic order)
for the desktop and then using
ShowIcon(myAppIco,TRUE)
to show that icon in the dialog window.
thx
$motty
|
|
|
|
|
What are you talking about? within the .rc file there is no ordering, lexicographical, numerical, alphabetical, none! All those words that you see there: IDI_Icon1 , IDI_Icon3 , __IDI_APPICON will be turned into a number when you compile the resources. Those numbers are defined in the .rc's header file. Look at the top few lines you will see something like #include "resources.h" then open that file. There you will find all the resource definitions. All you need do is find the name you assigned for your icon, and change it's number.
|
|
|
|
|
Hm.....I do understand, what YOU are talking about
But I DONT give them numbers (names, defines) in the .rc´s header file (the resources.h).
If I do what you suggest, I cannont use the icons for the xp style context menus anymore (dont ask why, thats just how it works)
During compiling they certainly all get number to be identified, but then again it looks like this compiletime number assignment was lexicographical if you DONT assign a number in the first place (which I cant).
Does this make it clearer to you ?
As I said, now it finally all works the way I want it to. But it does so without filling the resources.h.
When I use the VS resource editor, the icons (the way I use them now) have IDs like "IDI_ICON1" instead of what they have when they have a predefined number like IDI_ICON1, without the " " around them and you CANNOT reassign a number in the editor.
$motty
-- modified at 10:54 Friday 25th August, 2006
|
|
|
|
|
Hi every body,
Now, i want to write a program, it can send message to Yahoo users, but I don't know how to do it. Every body have experience about it, please tell me.
Thanks & Best Regards
xyz
|
|
|
|
|
Silly Boy wrote: Now, i want to...send message to Yahoo users,
Isn't that what Yahoo's IM is for?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Yahoo has an Activex Control for that. Try inserting activex control in dialog or anywhere u like.
regards
krishnan
If u can Dream... U can do it
|
|
|
|
|
Silly Boy wrote: Now, i want to write a program, it can send message to Yahoo users, but I don't know how to do it. Every body have experience about it, please tell me.
if you want to send EMAIL to yahoo users you have to use POP classes!... and if you want to send im to yahoo user .. this link might help
http://gaim.sourceforge.net/[^]
"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
|
|
|
|
|
Hi people, im using Update Resource to change a Bitmap in a DLL.
The bitmap is beign changed, but the new added bitmap hasn't a valid format.
I found this at expert exchange
char* buf = (char*)HeapAlloc (GetProcessHeap(), 0, dwFileSize + 2);
memcpy (buf, &dwFileSize, sizeof (dwFileSize));
memcpy (buf + 4, lpBuffer + 2, dwFileSize - 2);
This guy said that the resource BMP dont start with BM, instead the first 4 bytes are the lenght of the resource.
But a working BMP in the DLL begins with BM.
I tried without that code and the newly added BMP has an invalid format anyway.
Any suggestion??
Thanks a lot people
HANDLE hFile;<br />
DWORD dwFileSize, dwBytesRead;<br />
LPBYTE lpBuffer;<br />
<br />
hFile = CreateFile("test.bmp", GENERIC_READ, <br />
0,<br />
NULL,<br />
OPEN_EXISTING,<br />
FILE_ATTRIBUTE_NORMAL,<br />
NULL);<br />
<br />
if (INVALID_HANDLE_VALUE != hFile)<br />
{<br />
dwFileSize = GetFileSize(hFile, NULL);<br />
<br />
lpBuffer = new BYTE[dwFileSize];<br />
<br />
if (ReadFile(hFile, lpBuffer, dwFileSize, &dwBytesRead, NULL) != FALSE)<br />
{<br />
<br />
<br />
char* buf = (char*)HeapAlloc (GetProcessHeap(), 0, dwFileSize + 2);<br />
memcpy (buf, &dwFileSize, sizeof (dwFileSize));<br />
memcpy (buf + 4, lpBuffer + 2, dwFileSize - 2);<br />
<br />
<br />
<br />
if( UpdateResource( targetModule,<br />
RT_BITMAP,<br />
MAKEINTRESOURCE(1002),<br />
MAKELANGID(LANG_SPANISH,SUBLANG_SPANISH_ARGENTINA),<br />
(LPVOID)buf,<br />
sizeof(buf))) {<br />
<br />
MessageBox("Update OK", NULL, MB_OK);<br />
<br />
}<br />
else {<br />
MessageBox("Error in update", NULL, MB_OK);<br />
}<br />
<br />
if(EndUpdateResource(targetModule, FALSE)) <br />
MessageBox("Res changed", "ERROR", MB_OK);<br />
else<br />
MessageBox("Error updating res", "ERROR", MB_OK);<br />
<br />
<br />
}<br />
<br />
delete [] lpBuffer; <br />
<br />
CloseHandle(hFile);<br />
}
|
|
|
|
|