Richedit using win32, freezes when pasting to another program
-
- Posts: 7
- Joined: Jul 09, 2022 23:22
Richedit using win32, freezes when pasting to another program
Hello!
I'm trying to learn how to code win32 style programming in freebasic. I'm making a wordpad like program using the richedit control. I was able to learn how to format text and paragraphs and save and load, but I don't think I'm handling the clipboard correctly. I can copy and paste from within the program but if I copy from my program and paste in another, that program freezes. I can copy from another program into mine.
I'm not sure what part of my code to share, I think I'm missing something.
Where can I learn how to handle the clipboard when using the richedit control?
Thanks
I'm trying to learn how to code win32 style programming in freebasic. I'm making a wordpad like program using the richedit control. I was able to learn how to format text and paragraphs and save and load, but I don't think I'm handling the clipboard correctly. I can copy and paste from within the program but if I copy from my program and paste in another, that program freezes. I can copy from another program into mine.
I'm not sure what part of my code to share, I think I'm missing something.
Where can I learn how to handle the clipboard when using the richedit control?
Thanks
Re: Richedit using win32, freezes when pasting to another program
Hello
I know that there are far more better fb programmer than me
but in general you need to use sendmessage :
similar to this :
elseif uMsg = WM_COMMAND
select wparam
case 700 : SendMessage(hwnd,WM_CUT,0,0)
case 701 : SendMessage(hwnd,WM_COPY,0,0)
case 702 : SendMessage(hwnd,WM_PASTE,0,0)
case 703 : SendMessage(hwnd,EM_SETSEL ,0,-1)
end select
I know that there are far more better fb programmer than me
but in general you need to use sendmessage :
similar to this :
elseif uMsg = WM_COMMAND
select wparam
case 700 : SendMessage(hwnd,WM_CUT,0,0)
case 701 : SendMessage(hwnd,WM_COPY,0,0)
case 702 : SendMessage(hwnd,WM_PASTE,0,0)
case 703 : SendMessage(hwnd,EM_SETSEL ,0,-1)
end select
-
- Posts: 7
- Joined: Jul 09, 2022 23:22
Re: Richedit using win32, freezes when pasting to another program
I do have that part, I have it like this:
The menus work okay as long as I'm in my program, but the issue is when I copy or cut from it and paste to Libreoffice or Wordpad. I can paste to my own program but only if it's the same one.
If I run another one it doesn't work going from one to another.
It does paste to notepad.
I think it has something to do with delay rendering, also the clipboard goes away when I close the program.
I haven't yet been able to understand how to deal with the delay rendering or if that is even the cause.
Code: Select all
case IDM_Undo
SendMessage(GetFocus(), WM_UNDO, 0, 0)
case IDM_Cut
SendMessage(GetFocus(), WM_CUT, 0, 0)
case IDM_Copy
SendMessage(GetFocus(), WM_COPY, 0, 0)
case IDM_Paste
SendMessage(GetFocus(), WM_PASTE, 0, 0)
case IDM_Delete
SendMessage(GetFocus(), WM_CLEAR, 0, 0)
If I run another one it doesn't work going from one to another.
It does paste to notepad.
I think it has something to do with delay rendering, also the clipboard goes away when I close the program.
I haven't yet been able to understand how to deal with the delay rendering or if that is even the cause.
Re: Richedit using win32, freezes when pasting to another program
Aha i see you have problem when you copy and try to paste in another program
Maybe is problem in richedit version u use.
It is really hard to tell what might be wrong without whole code ?
Maybe is problem in richedit version u use.
It is really hard to tell what might be wrong without whole code ?
-
- Posts: 7
- Joined: Jul 09, 2022 23:22
Re: Richedit using win32, freezes when pasting to another program
Here is the entire code.
I also have a resource file where I defined the dialogs, menus, and accellerator keys and a header file with the constants from the rc file.
I know there must be something missing.
I also have a resource file where I defined the dialogs, menus, and accellerator keys and a header file with the constants from the rc file.
I know there must be something missing.
Code: Select all
'to do
'error checking on save doesn't work
'paste from doesn't work - Render callbacks are not correct
'how to get rtf to string instead of file. (that might fix the save error checking)
'fbc -s gui rich.rc rich.bas
#define WIN_INCLUDEALL
#include Once "Rich.bi"
#include Once "windows.bi"
#include Once "win\richedit.bi"
dim shared hInstance As HMODULE
dim shared PromptSave as BOOLEAN
dim shared filename as zstring * MAX_PATH + 1
dim shared richHwnd as HWND
dim shared hwnd as HWND
function file_openname(byval hWnd as HWND) as string
dim ofn as OPENFILENAME
with ofn
.lStructSize = sizeof(OPENFILENAME)
.hwndOwner = hWnd
.hInstance = GetModuleHandle(NULL)
.lpstrFilter = strptr(!"RTF Files, (*.rtf)\0*.RTF\0All Files, (*.*)\0*.*\0\0")
.lpstrCustomFilter = NULL
.nMaxCustFilter = 0
.nFilterIndex = 1
.lpstrFile = @filename
.nMaxFile = sizeof(filename)
.lpstrFileTitle = NULL
.nMaxFileTitle = 0
.lpstrInitialDir = NULL
.lpstrTitle = @"File Open"
.Flags = OFN_EXPLORER or OFN_FILEMUSTEXIST or OFN_PATHMUSTEXIST
.nFileOffset = 0
.nFileExtension = 0
.lpstrDefExt = strptr(!"rtf")
.lCustData = 0
.lpfnHook = NULL
.lpTemplateName = NULL
end with
if (GetOpenFileName(@ofn) = FALSE) then
return ""
else
return filename
end if
end function
function file_savename(byval hWnd as HWND) as string
dim ofn as OPENFILENAME
with ofn
.lStructSize = sizeof(OPENFILENAME)
.hwndOwner = hWnd
.hInstance = GetModuleHandle(NULL)
.lpstrFilter = strptr(!"RTF Files, (*.rtf)\0*.RTF\0All Files, (*.*)\0*.*\0\0")
.lpstrCustomFilter = NULL
.nMaxCustFilter = 0
.nFilterIndex = 1
.lpstrFile = @filename
.nMaxFile = sizeof(filename)
.lpstrFileTitle = NULL
.nMaxFileTitle = 0
.lpstrInitialDir = NULL
.lpstrTitle = @"File Save"
.Flags = OFN_EXPLORER or OFN_OVERWRITEPROMPT
.nFileOffset = 0
.nFileExtension = 0
.lpstrDefExt = strptr(!"rtf")
.lCustData = 0
.lpfnHook = NULL
.lpTemplateName = NULL
end with
if (GetSaveFileName(@ofn) = FALSE) then
return ""
else
return filename
end if
end function
function LoadCallback(dwCookie as DWORD_PTR, pbBuff as LPBYTE, cb as LONG, pcb as LONG ptr) as DWORD
ReadFile(cast(HANDLE, dwCookie), pbBuff, cb, pcb, NULL)
return 0
end function
function SaveCallback(dwCookie as DWORD_PTR, pbBuff as LPBYTE, cb as LONG, pcb as LONG ptr) as DWORD
WriteFile(cast(HANDLE, dwCookie), pbBuff, cb, pcb, NULL)
return 0
end function
function LoadRichEdit(hwndRich as HWND, szFileName as LPCTSTR) as BOOL
dim hFile as HANDLE
hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)
if hFile then
dim eds as EDITSTREAM
eds.dwCookie = cast(DWORD_PTR, hFile)
eds.dwError = 0
eds.pfnCallback = @LoadCallback
SendMessage(hwndRich, EM_STREAMIN, SF_RTF, cast(LPARAM, @eds))
CloseHandle(hFile)
return (eds.dwError = 0)
end if
return FALSE
end function
function SaveRichEdit(hwndRich as HWND, szFileName as LPCTSTR) as BOOL
dim hFile as HANDLE
hFile = CreateFile(szFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)
dim err_code as Long
if hFile <> FALSE then
dim eds as EDITSTREAM
eds.dwCookie = cast(DWORD_PTR, hFile)
eds.dwError = 0
eds.pfnCallback = @SaveCallback
SendMessage(hwndRich, EM_STREAMOUT, SF_RTF, cast(LPARAM, @eds))
CloseHandle(hFile)
err_code = eds.dwError
if err_code = 0 then
PromptSave = false
SetWindowText(hwnd, "Rich Text Edit - " + filename)
else
MessageBox(hwndRich , "code = " + str(err_code), "Error", MB_OK Or MB_ICONERROR)
end if
return (err_code)
else
MessageBox(hwndRich, "Could not create file.", "Error", MB_OK Or MB_ICONERROR)
end if
return FALSE
end function
sub quit(hwin as HWND)
if PromptSave then
dim response as Long
response = MessageBox(hWin, "Save before quit?", "Unsaved changes", MB_YESNOCANCEL)
if response = IDYES then
if filename = "" then filename = file_savename(hWin)
if filename <> "" then
SaveRichEdit(GetDlgItem(hWin, IDC_RED1), filename)
else
return
end if
end if
if response = IDCANCEL then
return
end if
end if
EndDialog(hWin, 0)
End
end sub
function get_field(hWin as HWND, control_id as Long) as Single
dim s as ZString * 25
GetWindowText(GetDlgItem(hWin, control_id), s, sizeof(s))
return val(s)
end function
function ParaDlgProc(ByVal hWin As HWND, ByVal uMsg As UINT, ByVal wParam As WPARAM, ByVal lParam As LPARAM) As Integer
dim id as Long
select case uMsg
case WM_INITDIALOG
dim pf as PARAFORMAT2
pf.cbSize = sizeof(PARAFORMAT2)
pf.dwMask = PFM_ALIGNMENT Or PFM_STARTINDENT Or PFM_OFFSET Or PFM_RIGHTINDENT or PFM_SPACEAFTER
SendMessage(richHwnd, EM_GETPARAFORMAT, 0, cast(LPARAM, @pf))
SetWindowText(GetDlgItem(hWin, IDC_FirstLine), Str(pf.dxStartIndent / 20))
SetWindowText(GetDlgItem(hWin, IDC_Right), Str(pf.dxRightIndent / 20))
SetWindowText(GetDlgItem(hWin, IDC_Left), Str(pf.dxOffset / 20 + pf.dxStartIndent / 20))
SetWindowText(GetDlgItem(hWin, IDC_SpaceAfter), Str(pf.dySpaceAfter / 20))
if pf.wAlignment = PFA_LEFT then CheckDlgButton(hWin, IDC_AlignLeft, BST_CHECKED)
if pf.wAlignment = PFA_CENTER then CheckDlgButton(hWin, IDC_AlignCenter, BST_CHECKED)
if pf.wAlignment = PFA_JUSTIFY then CheckDlgButton(hWin, IDC_AlignJustify, BST_CHECKED)
if pf.wAlignment = PFA_RIGHT then CheckDlgButton(hWin, IDC_AlignRight, BST_CHECKED)
case WM_COMMAND
id = LoWord(wParam)
select case id
case IDC_OK
dim pf as PARAFORMAT2
pf.cbSize = sizeof(PARAFORMAT2)
pf.dwMask = PFM_ALIGNMENT Or PFM_STARTINDENT Or PFM_OFFSET Or PFM_RIGHTINDENT or PFM_SPACEAFTER
pf.wAlignment = PFA_LEFT
if IsDlgButtonChecked(hWin, IDC_AlignLeft) = BST_CHECKED then pf.wAlignment = PFA_LEFT
if IsDlgButtonChecked(hWin, IDC_AlignCenter) = BST_CHECKED then pf.wAlignment = PFA_CENTER
if IsDlgButtonChecked(hWin, IDC_AlignJustify) = BST_CHECKED then pf.wAlignment = PFA_JUSTIFY
if IsDlgButtonChecked(hWin, IDC_AlignRight) = BST_CHECKED then pf.wAlignment = PFA_RIGHT
pf.dxStartIndent = get_field(hWin, IDC_FirstLine) * 20
pf.dxRightIndent = get_field(hWin, IDC_Right) * 20
pf.dxOffset = get_field(hWin, IDC_Left) * 20 - get_field(hWin, IDC_FirstLine) * 20
pf.dySpaceAfter = get_field(hWin, IDC_SpaceAfter) * 20
SendMessage(richHwnd, EM_SETPARAFORMAT, 0, cast(LPARAM, @pf))
EndDialog(hWin, 0)
case IDC_CANCEL
EndDialog(hWin, 0)
end select
case WM_CLOSE
EndDialog(hWin, 0)
case else
return false
end select
return true
end function
function DlgProc(ByVal hWin As HWND, ByVal uMsg As UINT, ByVal wParam As WPARAM, ByVal lParam As LPARAM) As Integer
dim As Long id, Event
dim rect As RECT
select case uMsg
case WM_INITDIALOG
richHwnd = GetDlgItem(hWin, IDC_RED1)
hwnd = hWin
SendMessage(richHwnd, EM_EXLIMITTEXT, 0, 1000000000)
SendMessage(richHwnd, EM_SETEVENTMASK, 0, ENM_CHANGE)
if Command(1) <> "" then
filename = Command(1)
LoadRichEdit(richHwnd, filename)
PromptSave = false
SetWindowText(hwnd, "Rich Text Edit - " + filename)
end if
RegisterClipboardFormat(CF_RTF)
RegisterClipboardFormat(CF_RETEXTOBJ)
case WM_CLOSE
Quit(hWin)
case WM_COMMAND
id = LoWord(wParam)
Event = HiWord(wParam)
select case id
case IDM_Save
if filename = "" then filename = file_savename(hWin)
if filename <> "" then SaveRichEdit(richHwnd, filename)
case IDM_SaveAs
filename = file_savename(hWin)
if filename <> "" then SaveRichEdit(richHwnd, filename)
case IDM_Open
if PromptSave then
if MessageBox(hWin, "Save before open?", "unsaved changes", MB_YESNO) = IDYES then
if filename = "" then filename = file_savename(hWin)
if filename <> "" then
SaveRichEdit(richHwnd, filename)
else
return true
end if
end if
end if
filename = file_openname(hWin)
if filename <> "" then
LoadRichEdit(richHwnd, filename)
PromptSave = false
SetWindowText(hwnd, "Rich Text Edit - " + filename)
end if
case IDM_Exit
Quit(hWin)
case IDM_Undo
SendMessage(GetFocus(), WM_UNDO, 0, 0)
case IDM_Cut
SendMessage(GetFocus(), WM_CUT, 0, 0)
case IDM_Copy
SendMessage(GetFocus(), WM_COPY, 0, 0)
case IDM_Paste
SendMessage(GetFocus(), WM_PASTE, 0, 0)
case IDM_Delete
SendMessage(GetFocus(), WM_CLEAR, 0, 0)
case IDM_SelectAll
SendMessage(GetFocus(), EM_SETSEL, 0, -1)
case IDM_Bold
dim font as CHARFORMAT
font.cbSize = sizeof(CHARFORMAT)
font.dwMask = CFM_BOLD
SendMessage(richHwnd, EM_GETCHARFORMAT, SCF_SELECTION, cast(LPARAM, @font))
if font.dwEffects And CFE_BOLD then
font.dwEffects = 0
else
font.dwEffects = CFE_BOLD
end if
font.dwMask = CFM_BOLD
SendMessage(richHwnd, EM_SETCHARFORMAT, SCF_SELECTION, cast(LPARAM, @font))
case IDM_Underline
dim font as CHARFORMAT
font.cbSize = sizeof(CHARFORMAT)
font.dwMask = CFM_UNDERLINE
SendMessage(richHwnd, EM_GETCHARFORMAT, SCF_SELECTION, cast(LPARAM, @font))
if font.dwEffects And CFE_UNDERLINE then
font.dwEffects = 0
else
font.dwEffects = CFE_UNDERLINE
end if
font.dwMask = CFM_UNDERLINE
SendMessage(richHwnd, EM_SETCHARFORMAT, SCF_SELECTION, cast(LPARAM, @font))
case IDM_Italic
dim font as CHARFORMAT
font.cbSize = sizeof(CHARFORMAT)
font.dwMask = CFM_ITALIC
SendMessage(richHwnd, EM_GETCHARFORMAT, SCF_SELECTION, cast(LPARAM, @font))
if font.dwEffects And CFE_ITALIC then
font.dwEffects = 0
else
font.dwEffects = CFE_ITALIC
end if
font.dwMask = CFM_ITALIC
SendMessage(richHwnd, EM_SETCHARFORMAT, SCF_SELECTION, cast(LPARAM, @font))
case IDM_Strikeout
dim font as CHARFORMAT
font.cbSize = sizeof(CHARFORMAT)
font.dwMask = CFM_STRIKEOUT
SendMessage(richHwnd, EM_GETCHARFORMAT, SCF_SELECTION, cast(LPARAM, @font))
if font.dwEffects And CFE_STRIKEOUT then
font.dwEffects = 0
else
font.dwEffects = CFE_STRIKEOUT
end if
font.dwMask = CFM_STRIKEOUT
SendMessage(richHwnd, EM_SETCHARFORMAT, SCF_SELECTION, cast(LPARAM, @font))
case IDM_Regular
dim font as CHARFORMAT
font.cbSize = sizeof(CHARFORMAT)
font.dwMask = CFM_UNDERLINE Or CFM_BOLD or CFM_ITALIC or CFM_STRIKEOUT
font.dwEffects = 0
SendMessage(richHwnd, EM_SETCHARFORMAT, SCF_SELECTION, cast(LPARAM, @font))
case IDM_Font
dim cf as CHOOSEFONT
dim lf as LOGFONT
dim hfont as HFONT
dim thischarformat as CHARFORMAT
thischarformat.cbSize = sizeof(CHARFORMAT)
thischarformat.dwMask = CFM_FACE or CFM_COLOR or CFM_SIZE or CFM_BOLD or CFM_ITALIC or CFM_UNDERLINE or CFM_STRIKEOUT
SendMessage(richHwnd, EM_GETCHARFORMAT, SCF_SELECTION, cast(LPARAM, @thischarformat))
ZeroMemory(@cf, sizeof(cf))
cf.lStructSize = sizeof(cf)
cf.hwndOwner = hWin
cf.lpLogFont = @lf
cf.Flags = CF_SCREENFONTS Or CF_EFFECTS or CF_INITTOLOGFONTSTRUCT
lf.lfFaceName = thischarformat.szFaceName
cf.rgbColors = thischarformat.crTextColor
lf.lfHeight = thischarformat.yHeight / 20
if thischarformat.dwEffects And CFE_BOLD then lf.lfWeight = FW_BOLD
if thischarformat.dwEffects And CFE_ITALIC then lf.lfItalic = TRUE
if thischarformat.dwEffects And CFE_UNDERLINE then lf.lfUnderline = TRUE
if thischarformat.dwEffects And CFE_STRIKEOUT then lf.lfStrikeout = TRUE
if ChooseFont(@cf) <> FALSE then
hfont = CreateFontIndirect(cf.lpLogFont)
thischarformat.dwMask = CFM_FACE or CFM_COLOR or CFM_SIZE or CFM_BOLD or CFM_ITALIC or CFM_UNDERLINE or CFM_STRIKEOUT
thischarformat.szFaceName = lf.lfFaceName
thischarformat.crTextColor = cf.rgbColors
thischarformat.yheight = lf.lfHeight * 20
thischarformat.dwEffects = 0
if lf.lfWeight = FW_BOLD then thischarformat.dwEffects = thischarformat.dwEffects Or CFE_BOLD
if lf.lfItalic <> FALSE then thischarformat.dwEffects = thischarformat.dwEffects Or CFE_ITALIC
if lf.lfUnderline <> FALSE then thischarformat.dwEffects = thischarformat.dwEffects Or CFE_UNDERLINE
if lf.lfStrikeOut <> FALSE then thischarformat.dwEffects = thischarformat.dwEffects Or CFE_STRIKEOUT
SendMessage(richHwnd, EM_SETCHARFORMAT, SCF_SELECTION, cast(LPARAM, @thischarformat))
end if
case IDM_Paragraph
DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_PARA), hWin, @ParaDlgProc, NULL)
end select
if Event = EN_CHANGE then
if PromptSave = false then
PromptSave = true
SetWindowText(hWin, "Rich Text Edit * - " + filename)
end if
end if
case WM_SIZE
GetClientRect(hWin,@rect)
MoveWindow(richHwnd, 0, 0, rect.right, rect.bottom, TRUE)
case WM_INITMENUPOPUP
if lParam = 2 then
dim thischarformat as CHARFORMAT
thischarformat.cbSize = sizeof(CHARFORMAT)
thischarformat.dwMask = CFM_BOLD or CFM_ITALIC or CFM_UNDERLINE or CFM_STRIKEOUT
SendMessage(richHwnd, EM_GETCHARFORMAT, SCF_SELECTION, cast(LPARAM, @thischarformat))
CheckMenuItem(GetMenu(hWin), IDM_Bold, MF_UNCHECKED Or MF_BYCOMMAND)
CheckMenuItem(GetMenu(hWin), IDM_Italic, MF_UNCHECKED Or MF_BYCOMMAND)
CheckMenuItem(GetMenu(hWin), IDM_Underline, MF_UNCHECKED Or MF_BYCOMMAND)
CheckMenuItem(GetMenu(hWin), IDM_Strikeout, MF_UNCHECKED Or MF_BYCOMMAND)
if thischarformat.dwEffects And CFE_BOLD then CheckMenuItem(GetMenu(hWin), IDM_Bold, MF_CHECKED Or MF_BYCOMMAND)
if thischarformat.dwEffects And CFE_ITALIC then CheckMenuItem(GetMenu(hWin), IDM_Italic, MF_CHECKED Or MF_BYCOMMAND)
if thischarformat.dwEffects And CFE_UNDERLINE then CheckMenuItem(GetMenu(hWin), IDM_Underline, MF_CHECKED Or MF_BYCOMMAND)
if thischarformat.dwEffects And CFE_STRIKEOUT then CheckMenuItem(GetMenu(hWin), IDM_Strikeout, MF_CHECKED Or MF_BYCOMMAND)
end if
case else
return FALSE
end select
return TRUE
end function
dim hAccel as HACCEL
dim win as hWND
dim msg as MSG
hInstance = GetModuleHandle(NULL)
hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCEL1))
PromptSave = false
LoadLibrary("Msftedit.dll")
win = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DLG1), NULL, @DlgProc)
while GetMessage(@msg, NULL, 0, 0)
if TranslateAccelerator(win, hAccel, @msg) = 0 then
IsDialogMessage(win, @msg)
end if
wend
ExitProcess(0)
Re: Richedit using win32, freezes when pasting to another program
sorry ..butdon't want to compile without include file
#include Once "Rich.bi"
post this too
#include Once "Rich.bi"
post this too
-
- Posts: 7
- Joined: Jul 09, 2022 23:22
Re: Richedit using win32, freezes when pasting to another program
Here are the other two files
Rich.bi
Rich.rc
Rich.bi
Code: Select all
#define IDC_Left 1107
#define IDC_Right 1108
#define IDC_STC4 1110
#define IDC_AlignLeft 1109
#define IDC_AlignCenter 1111
#define IDC_AlignRight 1112
#define IDC_AlignJustify 1113
#define IDC_SpaceAfter 1115
#define IDR_ACCEL1 1
Code: Select all
#define IDM_File 10001
#define IDM_ 10002
#define IDD_DLG1 1000
#define IDC_RED1 1002
#define IDR_MENU1 10000
#define IDM_Open 10004
#define IDM_Save 10001
#define IDM_SaveAs 10003
#define IDM_Exit 10005
#define IDM_Undo 10011
#define IDM_Cut 10006
#define IDM_Copy 10007
#define IDM_Paste 10008
#define IDM_Delete 10009
#define IDM_SelectAll 10010
#define IDM_Format 10018
#define IDM_Bold 10012
#define IDM_Underline 10013
#define IDM_Italic 10014
#define IDM_Regular 10015
#define IDM_Strikeout 10002
#define IDM_Font 10016
#define IDM_Paragraph 10017
#define IDR_ACCEL1 1
#define IDM_Save 10001
#define IDM_Open 10004
#define IDM_Quit 10005
#define IDM_Bold 10012
#define IDM_Italic 10014
#define IDM_Underline 10013
#define IDM_Regular 10015
#define IDM_Strikeout 10002
#define IDD_PARA 1100
#define IDC_STC1 1101
#define IDC_FirstLine 1106
#define IDC_Left 1107
#define IDC_Right 1108
#define IDC_SpaceAfter 1115
#define IDC_AlignLeft 1109
#define IDC_AlignCenter 1111
#define IDC_AlignJustify 1113
#define IDC_AlignRight 1112
#define IDC_OK 1104
#define IDC_Cancel 1105
#define IDC_STC2 1102
#define IDC_STC3 1103
#define IDC_STC4 1110
#define IDC_STC5 1114
IDD_DLG1 DIALOGEX 6,5,412,295
CAPTION "Rich Text Edit"
FONT 8,"MS Sans Serif",400,0,0
MENU IDR_MENU1
STYLE 0x10CF0800
BEGIN
CONTROL "",IDC_RED1,"RICHEDIT50W",0x50219044,0,0,411,294,0x00000200
END
IDR_MENU1 MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Open\tCtrl+O",IDM_Open
MENUITEM "&Save\tCtrl+S",IDM_Save
MENUITEM "Save &As",IDM_SaveAs
MENUITEM "E&xit\tCtrl+Q",IDM_Exit
END
POPUP "&Edit"
BEGIN
MENUITEM "&Undo\tCtrl+Z",IDM_Undo
MENUITEM "Cu&t\tCtrl+X",IDM_Cut
MENUITEM "&Copy\tCtrl+C",IDM_Copy
MENUITEM "&Paste\tCtrl+V",IDM_Paste
MENUITEM "&Delete",IDM_Delete
MENUITEM "Select &All\tCtrl+A",IDM_SelectAll
END
POPUP "F&ormat"
BEGIN
MENUITEM "&Bold\tCtrl+B",IDM_Bold
MENUITEM "&Underline\tCtrl+U",IDM_Underline
MENUITEM "&Italic\tCtrl+I",IDM_Italic
MENUITEM "&Regular\tCtrl+M",IDM_Regular
MENUITEM "&Strikethrough\tCtrl+K",IDM_Strikeout
MENUITEM "&Font...",IDM_Font
MENUITEM "&Paragraph...",IDM_Paragraph
END
END
IDR_ACCEL1 ACCELERATORS
BEGIN
83,IDM_Save,VIRTKEY,CONTROL,NOINVERT
79,IDM_Open,VIRTKEY,CONTROL,NOINVERT
81,IDM_Quit,VIRTKEY,CONTROL,NOINVERT
66,IDM_Bold,VIRTKEY,CONTROL,NOINVERT
73,IDM_Italic,VIRTKEY,CONTROL,NOINVERT
85,IDM_Underline,VIRTKEY,CONTROL,NOINVERT
77,IDM_Regular,VIRTKEY,CONTROL,NOINVERT
75,IDM_Strikeout,VIRTKEY,CONTROL,NOINVERT
END
IDD_PARA DIALOGEX -2,-16,208,196
CAPTION "Paragraph format"
FONT 8,"MS Sans Serif",0,0,0
STYLE 0x10C80000
BEGIN
CONTROL "First Line",IDC_STC1,"Static",0x50000000,33,15,54,9
CONTROL "0",IDC_FirstLine,"Edit",0x50010000,90,15,72,15,0x00000200
CONTROL "0",IDC_Left,"Edit",0x50010000,90,30,72,15,0x00000200
CONTROL "0",IDC_Right,"Edit",0x50010000,90,45,72,15,0x00000200
CONTROL "0",IDC_SpaceAfter,"Edit",0x50010000,90,60,72,15,0x00000200
CONTROL "&Left",IDC_AlignLeft,"Button",0x50010009,9,117,54,9
CONTROL "&Centered",IDC_AlignCenter,"Button",0x50010009,9,132,54,9
CONTROL "&Justified",IDC_AlignJustify,"Button",0x50010009,9,147,54,9
CONTROL "&Right",IDC_AlignRight,"Button",0x50010009,9,162,54,9
CONTROL "OK",IDC_OK,"Button",0x50010001,90,162,45,15
CONTROL "Cancel",IDC_Cancel,"Button",0x50010000,144,162,45,15
CONTROL "Left",IDC_STC2,"Static",0x50000000,33,30,54,9
CONTROL "Right",IDC_STC3,"Static",0x50000000,33,45,54,9
CONTROL "Alignment",IDC_STC4,"Static",0x50000000,9,102,54,9
CONTROL "Space After",IDC_STC5,"Static",0x50000000,33,63,54,9
END
Re: Richedit using win32, freezes when pasting to another program
Thanks on files Hitomi
So i try to compile on FB 1.09
so i include all
Rich.bi
Rich.rc
and again i get Compile Failure!
problem on my win7_64 bit :
so now i am wondering how you can compile it ?
Do you duplicate include maybe ?
So i try to compile on FB 1.09
so i include all
Rich.bi
Rich.rc
and again i get Compile Failure!
problem on my win7_64 bit :
ofn structure is filled wrong\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\RichEditCopy.bas(25) warning 4(2): Suspicious pointer assignment
D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\RichEditCopy.bas(34) warning 4(2): Suspicious pointer assignment
D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\RichEditCopy.bas(38) warning 4(2): Suspicious pointer assignment
D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\RichEditCopy.bas(59) warning 4(2): Suspicious pointer assignment
D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\RichEditCopy.bas(68) warning 4(2): Suspicious pointer assignment
D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\RichEditCopy.bas(72) warning 4(2): Suspicious pointer assignment
so now i am wondering how you can compile it ?
Do you duplicate include maybe ?
Re: Richedit using win32, freezes when pasting to another program
then i look into my old FBScin scintilla based editor example
and found different fileOpen structure is used
and heck new compiler complain about wrong scalar conversion
OMG
here is topic:
viewtopic.php?t=31387
and found different fileOpen structure is used
and heck new compiler complain about wrong scalar conversion
OMG
here is topic:
viewtopic.php?t=31387
Re: Richedit using win32, freezes when pasting to another program
The problem is not processing the messages that are translated or that IsDialogMessage doesn't touch. Something like this is what's required:HitomiHoshino wrote: ↑Jun 01, 2023 12:15Code: Select all
while GetMessage(@msg, NULL, 0, 0) if TranslateAccelerator(win, hAccel, @msg) = 0 then IsDialogMessage(win, @msg) end if wend
Code: Select all
while GetMessage(@msg, NULL, 0, 0)
dim as Long wasTranslated = TranslateAccelerator(win, hAccel, @msg)
if IsDialogMessage(win, @msg) = 0 Then
if wasTranslated = 0 Then TranslateMessage(@msg)
DispatchMessage(@msg)
end if
wend
-
- Posts: 7
- Joined: Jul 09, 2022 23:22
Re: Richedit using win32, freezes when pasting to another program
Sorry, I noticed I didn't get all of rich.bi copied
Code: Select all
#define IDD_DLG1 1000
#define IDC_RED1 1002
#define IDR_MENU1 10000
#define IDM_Save 10001
#define IDM_SaveAs 10003
#define IDM_Open 10004
#define IDM_Exit 10005
#define IDM_Cut 10006
#define IDM_Copy 10007
#define IDM_Paste 10008
#define IDM_Delete 10009
#define IDM_SelectAll 10010
#define IDM_Undo 10011
#define IDM_Bold 10012
#define IDM_Underline 10013
#define IDM_Italic 10014
#define IDM_Regular 10015
#define IDM_Strikeout 10002
#define IDM_Font 10016
#define IDM_Paragraph 10017
#define IDM_Format 10018
#define IDD_PARA 1100
#define IDC_STC1 1101
#define IDC_STC2 1102
#define IDC_STC3 1103
#define IDC_OK 1104
#define IDC_Cancel 1105
#define IDC_FirstLine 1106
#define IDC_Left 1107
#define IDC_Right 1108
#define IDC_STC4 1110
#define IDC_AlignLeft 1109
#define IDC_AlignCenter 1111
#define IDC_AlignRight 1112
#define IDC_AlignJustify 1113
#define IDC_SpaceAfter 1115
#define IDR_ACCEL1 1
-
- Posts: 7
- Joined: Jul 09, 2022 23:22
Re: Richedit using win32, freezes when pasting to another program
@adeyblue
This worked!
Thank you!
This worked!
Thank you!
Re: Richedit using win32, freezes when pasting to another program
Worked ???
How worked ..i only saw that stuck in memory ?
How worked ..i only saw that stuck in memory ?
d:/freebasic-1.09.0-win64/freebasic-1.09.0-win64/fbc.exe" -b "D:/FreeBASIC-1.09.0-win64/FreeBASIC-1.09.0-win64/RichEditCopy.bas" -s gui
d:\freebasic-1.09.0-win64\freebasic-1.09.0-win64\bin\win64\ld.exe: cannot open output file D:/FreeBASIC-1.09.0-win64/FreeBASIC-1.09.0-win64/RichEditCopy.exe: Permission denied
D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\RichEditCopy.bas(25) warning 4(2): Suspicious pointer assignment
D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\RichEditCopy.bas(34) warning 4(2): Suspicious pointer assignment
D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\RichEditCopy.bas(38) warning 4(2): Suspicious pointer assignment
D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\RichEditCopy.bas(59) warning 4(2): Suspicious pointer assignment
D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\RichEditCopy.bas(68) warning 4(2): Suspicious pointer assignment
D:\FreeBASIC-1.09.0-win64\FreeBASIC-1.09.0-win64\RichEditCopy.bas(72) warning 4(2): Suspicious pointer assignment
-
- Posts: 7
- Joined: Jul 09, 2022 23:22
Re: Richedit using win32, freezes when pasting to another program
I didn't get errors like that when I compiled it. I didn't have any warnings either.
The command I used is fbc -s gui rich.rc rich.bas
I've gotten that permission denied message if I was still running the program while compiling it again.
The version of freebasic I'm using should be the same as yours
FreeBASIC Compiler - Version 1.09.0 (2021-12-31), built for win64 (64bit)
Copyright (C) 2004-2021 The FreeBASIC development team.
standalone
I'm on Windows 10.
I also tried to build it in a windows XP virtual machine with the 32 bit version and that worked too.
Odd thing is when I try to paste images into it in that version it doesn't do anything, but on the windows 10 64 bit one it does allow me to paste images.
The command I used is fbc -s gui rich.rc rich.bas
I've gotten that permission denied message if I was still running the program while compiling it again.
The version of freebasic I'm using should be the same as yours
FreeBASIC Compiler - Version 1.09.0 (2021-12-31), built for win64 (64bit)
Copyright (C) 2004-2021 The FreeBASIC development team.
standalone
I'm on Windows 10.
I also tried to build it in a windows XP virtual machine with the 32 bit version and that worked too.
Odd thing is when I try to paste images into it in that version it doesn't do anything, but on the windows 10 64 bit one it does allow me to paste images.
Re: Richedit using win32, freezes when pasting to another program
i use same compile arguments but on win7-64bit