changeset 2034:89d62197124b

Visual C in C++ mode complains about missing const declarations in paramaters. So adding const to any string parameters which are not written to. Probably going to require changes to the other platforms due to header changes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 17 Nov 2019 03:13:37 +0000
parents d81d2ea806c6
children ea303d356419
files dw.h win/browser.c win/dw.c win/edge.cpp
diffstat 4 files changed, 170 insertions(+), 164 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Sat Nov 16 09:43:17 2019 +0000
+++ b/dw.h	Sun Nov 17 03:13:37 2019 +0000
@@ -1580,37 +1580,37 @@
 int API dw_window_lower(HWND handle);
 int API dw_window_destroy(HWND handle);
 void API dw_window_redraw(HWND handle);
-int API dw_window_set_font(HWND handle, char *fontname);
+int API dw_window_set_font(HWND handle, const char *fontname);
 char * API dw_window_get_font(HWND handle);
 int API dw_window_set_color(HWND handle, unsigned long fore, unsigned long back);
-HWND API dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle);
+HWND API dw_window_new(HWND hwndOwner, const char *title, unsigned long flStyle);
 HWND API dw_box_new(int type, int pad);
 HWND API dw_scrollbox_new(int type, int pad);
 int API dw_scrollbox_get_pos( HWND handle, int orient );
 int API dw_scrollbox_get_range( HWND handle, int orient );
-HWND API dw_groupbox_new(int type, int pad, char *title);
+HWND API dw_groupbox_new(int type, int pad, const char *title);
 DW_DEPRECATED(HWND API dw_mdi_new(unsigned long id), "Due to lack of full Mac support consider avoiding this function.");
 HWND API dw_bitmap_new(unsigned long id);
-HWND API dw_bitmapbutton_new(char *text, unsigned long id);
-HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename);
-HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *str, int len);
+HWND API dw_bitmapbutton_new(const char *text, unsigned long id);
+HWND API dw_bitmapbutton_new_from_file(const char *text, unsigned long id, const char *filename);
+HWND API dw_bitmapbutton_new_from_data(const char *text, unsigned long id, const char *str, int len);
 HWND API dw_container_new(unsigned long id, int multi);
 HWND API dw_tree_new(unsigned long id);
-HWND API dw_text_new(char *text, unsigned long id);
-HWND API dw_status_text_new(char *text, unsigned long id);
+HWND API dw_text_new(const char *text, unsigned long id);
+HWND API dw_status_text_new(const char *text, unsigned long id);
 HWND API dw_mle_new(unsigned long id);
 HWND API dw_entryfield_new(char *text, unsigned long id);
-HWND API dw_entryfield_password_new(char *text, ULONG id);
+HWND API dw_entryfield_password_new(const char *text, ULONG id);
 HWND API dw_combobox_new(char *text, unsigned long id);
 HWND API dw_button_new(char *text, unsigned long id);
-HWND API dw_spinbutton_new(char *text, unsigned long id);
+HWND API dw_spinbutton_new(char const *text, unsigned long id);
 HWND API dw_radiobutton_new(char *text, ULONG id);
 HWND API dw_percent_new(unsigned long id);
 HWND API dw_slider_new(int vertical, int increments, ULONG id);
 HWND API dw_scrollbar_new(int vertical, ULONG id);
 HWND API dw_checkbox_new(char *text, unsigned long id);
 HWND API dw_listbox_new(unsigned long id, int multi);
-void API dw_listbox_append(HWND handle, char *text);
+void API dw_listbox_append(HWND handle, const char *text);
 void API dw_listbox_insert(HWND handle, char *text, int pos);
 void API dw_listbox_list_append(HWND handle, char **text, int count);
 void API dw_listbox_clear(HWND handle);
@@ -1619,7 +1619,7 @@
 void API dw_listbox_select(HWND handle, int index, int state);
 void API dw_listbox_delete(HWND handle, int index);
 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length);
-void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer);
+void API dw_listbox_set_text(HWND handle, unsigned int index, const char *buffer);
 int API dw_listbox_selected(HWND handle);
 int API dw_listbox_selected_multi(HWND handle, int where);
 void API dw_percent_set_pos(HWND handle, unsigned int position);
@@ -1636,11 +1636,11 @@
 void API dw_window_set_gravity(HWND handle, int horz, int vert);
 void API dw_window_set_style(HWND handle, unsigned long style, unsigned long mask);
 void API dw_window_set_icon(HWND handle, HICN icon);
-void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename);
-void API dw_window_set_bitmap_from_data(HWND handle, unsigned long id, char *data, int len);
+void API dw_window_set_bitmap(HWND handle, unsigned long id, const char *filename);
+void API dw_window_set_bitmap_from_data(HWND handle, unsigned long id, const char *data, int len);
 char * API dw_window_get_text(HWND handle);
-void API dw_window_set_text(HWND handle, char *text);
-void API dw_window_set_tooltip(HWND handle, char *bubbletext);
+void API dw_window_set_text(HWND handle, const char *text);
+void API dw_window_set_tooltip(HWND handle, const char *bubbletext);
 int API dw_window_set_border(HWND handle, int border);
 void API dw_window_disable(HWND handle);
 void API dw_window_enable(HWND handle);
@@ -1670,11 +1670,11 @@
 long API dw_spinbutton_get_pos(HWND handle);
 int API dw_checkbox_get(HWND handle);
 void API dw_checkbox_set(HWND handle, int value);
-HTREEITEM API dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata);
-HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata);
+HTREEITEM API dw_tree_insert(HWND handle, const char *title, HICN icon, HTREEITEM parent, void *itemdata);
+HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, const char *title, HICN icon, HTREEITEM parent, void *itemdata);
 void API dw_tree_clear(HWND handle);
 void API dw_tree_item_delete(HWND handle, HTREEITEM item);
-void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon);
+void API dw_tree_item_change(HWND handle, HTREEITEM item, const char *title, HICN icon);
 void API dw_tree_item_expand(HWND handle, HTREEITEM item);
 void API dw_tree_item_collapse(HWND handle, HTREEITEM item);
 void API dw_tree_item_select(HWND handle, HTREEITEM item);
@@ -1684,15 +1684,15 @@
 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item);
 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator);
 HICN API dw_icon_load(unsigned long module, unsigned long id);
-HICN API dw_icon_load_from_file(char *filename);
-HICN API dw_icon_load_from_data(char *data, int len);
+HICN API dw_icon_load_from_file(const char *filename);
+HICN API dw_icon_load_from_data(const char *data, int len);
 void API dw_icon_free(HICN handle);
 void * API dw_container_alloc(HWND handle, int rowcount);
 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data);
 void API dw_container_change_item(HWND handle, int column, int row, void *data);
 void API dw_container_set_column_width(HWND handle, int column, int width);
-void API dw_container_set_row_title(void *pointer, int row, char *title);
-void API dw_container_change_row_title(HWND handle, int row, char *title);
+void API dw_container_set_row_title(void *pointer, int row, const char *title);
+void API dw_container_change_row_title(HWND handle, int row, const char *title);
 void API dw_container_set_row_data(void *pointer, int row, void *data);
 void API dw_container_change_row_data(HWND handle, int row, void *data);
 void API dw_container_insert(HWND handle, void *pointer, int rowcount);
@@ -1701,21 +1701,21 @@
 char * API dw_container_query_start(HWND handle, unsigned long flags);
 char * API dw_container_query_next(HWND handle, unsigned long flags);
 void API dw_container_scroll(HWND handle, int direction, long rows);
-void API dw_container_cursor(HWND handle, char *text);
+void API dw_container_cursor(HWND handle, const char *text);
 void API dw_container_cursor_by_data(HWND handle, void *data);
-void API dw_container_delete_row(HWND handle, char *text);
+void API dw_container_delete_row(HWND handle, const char *text);
 void API dw_container_delete_row_by_data(HWND handle, void *data);
 void API dw_container_optimize(HWND handle);
 void API dw_container_set_stripe(HWND handle, unsigned long oddcolor, unsigned long evencolor);
-void API dw_filesystem_set_column_title(HWND handle, char *title);
+void API dw_filesystem_set_column_title(HWND handle, const char *title);
 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count);
 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data);
-void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon);
+void API dw_filesystem_set_file(HWND handle, void *pointer, int row, const char *filename, HICN icon);
 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data);
-void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon);
+void API dw_filesystem_change_file(HWND handle, int row, const char *filename, HICN icon);
 int API dw_container_get_column_type(HWND handle, int column);
 int API dw_filesystem_get_column_type(HWND handle, int column);
-void API dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext);
+void API dw_taskbar_insert(HWND handle, HICN icon, const char *bubbletext);
 void API dw_taskbar_delete(HWND handle, HICN icon);
 int API dw_screen_width(void);
 int API dw_screen_height(void);
@@ -1723,8 +1723,8 @@
 HWND API dw_notebook_new(unsigned long id, int top);
 unsigned long API dw_notebook_page_new(HWND handle, unsigned long flags, int front);
 void API dw_notebook_page_destroy(HWND handle, unsigned int pageid);
-void API dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text);
-void API dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text);
+void API dw_notebook_page_set_text(HWND handle, unsigned long pageid, const char *text);
+void API dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, const char *text);
 void API dw_notebook_page_set(HWND handle, unsigned int pageid);
 unsigned long API dw_notebook_page_get(HWND handle);
 void API dw_notebook_pack(HWND handle, unsigned long pageid, HWND page);
@@ -1762,73 +1762,73 @@
 void API dw_color_foreground_set(unsigned long value);
 void API dw_color_background_set(unsigned long value);
 unsigned long API dw_color_choose(unsigned long value);
-char * API dw_font_choose(char *currfont);
+char * API dw_font_choose(const char *currfont);
 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y);
 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2);
 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height);
 void API dw_draw_polygon(HWND handle, HPIXMAP pixmap, int fill, int npoints, int *x, int *y);
 void API dw_draw_arc(HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2);
-void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text);
-void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height);
-void API dw_font_set_default(char *fontname);
+void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, const char *text);
+void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, const char *text, int *width, int *height);
+void API dw_font_set_default(const char *fontname);
 void API dw_flush(void);
 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc);
 int API dw_pixmap_stretch_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight);
 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth);
-HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename);
-HPIXMAP API dw_pixmap_new_from_data(HWND handle, char *data, int len);
+HPIXMAP API dw_pixmap_new_from_file(HWND handle, const char *filename);
+HPIXMAP API dw_pixmap_new_from_data(HWND handle, const char *data, int len);
 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id);
 void API dw_pixmap_set_transparent_color( HPIXMAP pixmap, ULONG color );
-int API dw_pixmap_set_font(HPIXMAP pixmap, char *fontname);
+int API dw_pixmap_set_font(HPIXMAP pixmap, const char *fontname);
 void API dw_pixmap_destroy(HPIXMAP pixmap);
 void API dw_beep(int freq, int dur);
-void API dw_debug(char *format, ...);
-int API dw_messagebox(char *title, int flags, char *format, ...);
+void API dw_debug(const char *format, ...);
+int API dw_messagebox(const char *title, int flags, const char *format, ...);
 void API dw_environment_query(DWEnv *env);
-int API dw_exec(char *program, int type, char **params);
+int API dw_exec(const char *program, int type, char **params);
 int API dw_browse(char *url);
-char * API dw_file_browse(char *title, char *defpath, char *ext, int flags);
+char * API dw_file_browse(const char *title, const char *defpath, char *ext, int flags);
 char * API dw_user_dir(void);
 char * API dw_app_dir(void);
 DWDialog * API dw_dialog_new(void *data);
 int API dw_dialog_dismiss(DWDialog *dialog, void *result);
 void * API dw_dialog_wait(DWDialog *dialog);
-void API dw_window_set_data(HWND window, char *dataname, void *data);
-void * API dw_window_get_data(HWND window, char *dataname);
+void API dw_window_set_data(HWND window, const char *dataname, void *data);
+void * API dw_window_get_data(HWND window, const char *dataname);
 int API dw_module_load(char *name, HMOD *handle);
-int API dw_module_symbol(HMOD handle, char *name, void**func);
+int API dw_module_symbol(HMOD handle, const char *name, void**func);
 int API dw_module_close(HMOD handle);
 int API dw_timer_connect(int interval, void *sigfunc, void *data);
 void API dw_timer_disconnect(int id);
-void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data);
-void API dw_signal_connect_data(HWND window, char *signame, void *sigfunc, void *discfunc, void *data);
+void API dw_signal_connect(HWND window, const char *signame, void *sigfunc, void *data);
+void API dw_signal_connect_data(HWND window, const char *signame, void *sigfunc, void *discfunc, void *data);
 void API dw_signal_disconnect_by_window(HWND window);
 void API dw_signal_disconnect_by_data(HWND window, void *data);
-void API dw_signal_disconnect_by_name(HWND window, char *signame);
-HEV API dw_named_event_new(char *name);
-HEV API dw_named_event_get(char *name);
+void API dw_signal_disconnect_by_name(HWND window, const char *signame);
+HEV API dw_named_event_new(const char *name);
+HEV API dw_named_event_get(const char *name);
 int API dw_named_event_reset(HEV eve);
 int API dw_named_event_post(HEV eve);
 int API dw_named_event_wait(HEV eve, unsigned long timeout);
 int API dw_named_event_close(HEV eve);
-HSHM API dw_named_memory_new(void **dest, int size, char *name);
-HSHM API dw_named_memory_get(void **dest, int size, char *name);
+HSHM API dw_named_memory_new(void **dest, int size, const char *name);
+HSHM API dw_named_memory_get(void **dest, int size, const char *name);
 int API dw_named_memory_free(HSHM handle, void *ptr);
 void API dw_html_action(HWND hwnd, int action);
-int API dw_html_raw(HWND hwnd, char *string);
-int API dw_html_url(HWND hwnd, char *url);
-int API dw_html_javascript_run(HWND hwnd, char *script, void *scriptdata);
+int API dw_html_raw(HWND hwnd, const char *string);
+int API dw_html_url(HWND hwnd, const char *url);
+int API dw_html_javascript_run(HWND hwnd, const char *script, void *scriptdata);
 HWND API dw_html_new(unsigned long id);
 char * API dw_clipboard_get_text(void);
-void API dw_clipboard_set_text( char *str, int len );
+void API dw_clipboard_set_text(const char *str, int len);
 HWND API dw_calendar_new(unsigned long id);
-void API dw_calendar_set_date( HWND window, unsigned int year, unsigned int month, unsigned int day );
-void API dw_calendar_get_date( HWND window, unsigned int *year, unsigned int *month, unsigned int *day );
+void API dw_calendar_set_date(HWND window, unsigned int year, unsigned int month, unsigned int day);
+void API dw_calendar_get_date(HWND window, unsigned int *year, unsigned int *month, unsigned int *day);
 HPRINT API dw_print_new(char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata);
 int API dw_print_run(HPRINT print, unsigned long flags);
 void API dw_print_cancel(HPRINT print);
-wchar_t * API dw_utf8_to_wchar(char *utf8string);
-char * API dw_wchar_to_utf8(wchar_t *wstring);
+wchar_t * API dw_utf8_to_wchar(const char *utf8string);
+char * API dw_wchar_to_utf8(const wchar_t *wstring);
 /* Exported for language bindings */
 void API _dw_init_thread(void);
 void API _dw_deinit_thread(void);
--- a/win/browser.c	Sat Nov 16 09:43:17 2019 +0000
+++ b/win/browser.c	Sun Nov 17 03:13:37 2019 +0000
@@ -32,8 +32,8 @@
 #include "dw.h"
 
 /* Import the character conversion functions from dw.c */
-LPWSTR _myUTF8toWide(char *utf8string, void *outbuf);
-char *_myWideToUTF8(LPWSTR widestring, void *outbuf);
+LPWSTR _myUTF8toWide(const char *utf8string, void *outbuf);
+char *_myWideToUTF8(LPCWSTR widestring, void *outbuf);
 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL)
 #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL)
 LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2);
@@ -1362,7 +1362,7 @@
  * this function to display numerous pages in the specified window.
  */
 
-int _dw_html_raw(HWND hwnd, char *string)
+int _dw_html_raw(HWND hwnd, const char *string)
 {	
 	IWebBrowser2	*webBrowser2;
 	LPDISPATCH		lpDispatch;
@@ -1487,7 +1487,7 @@
  * this function to display numerous pages in the specified window.
  */
 
-int _dw_html_url(HWND hwnd, char *url)
+int _dw_html_url(HWND hwnd, const char *url)
 {
 	IWebBrowser2	*webBrowser2;
 	VARIANT			myURL;
@@ -1557,7 +1557,7 @@
  * RETURNS: 0 if success, or non-zero if an error.
  */
 
-int _dw_html_javascript_run(HWND hwnd, char *script, void *scriptdata)
+int _dw_html_javascript_run(HWND hwnd, const char *script, void *scriptdata)
 {
 	IWebBrowser2	*webBrowser2;
 	IHTMLWindow2	*htmlWindow2;
--- a/win/dw.c	Sat Nov 16 09:43:17 2019 +0000
+++ b/win/dw.c	Sun Nov 17 03:13:37 2019 +0000
@@ -320,7 +320,7 @@
 void _resize_notebook_page(HWND handle, int pageid);
 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y);
 int _lookup_icon(HWND handle, HICON hicon, int type);
-HFONT _acquire_font(HWND handle, char *fontname);
+HFONT _acquire_font(HWND handle, const char *fontname);
 void _click_default(HWND handle);
 void _do_resize(Box *thisbox, int x, int y);
 
@@ -495,7 +495,7 @@
 #ifdef UNICODE
 /* Macro and internal function to convert UTF8 to Unicode wide characters */
 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL)
-LPWSTR _myUTF8toWide(char *utf8string, void *outbuf)
+LPWSTR _myUTF8toWide(const char *utf8string, void *outbuf)
 {
    LPWSTR retbuf = outbuf;
    
@@ -504,7 +504,7 @@
    return retbuf;
 }
 #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL)
-char *_myWideToUTF8(LPWSTR widestring, void *outbuf)
+char *_myWideToUTF8(LPCWSTR widestring, void *outbuf)
 {
    char *retbuf = outbuf;
    
@@ -577,7 +577,7 @@
 };
 
 /* Section for loading files of types besides BMP and ICO and return HBITMAP or HICON */
-void *_dw_load_gpbitmap( char *filename )
+void *_dw_load_gpbitmap(const char *filename)
 {
    int i, wclen = (int)(strlen(filename) + 6) * sizeof(wchar_t);
    char *file = _alloca(strlen(filename) + 6);
@@ -601,7 +601,7 @@
 }
 
 /* Try to load the appropriate image and return the HBITMAP handle */
-HBITMAP _dw_load_bitmap(char *filename, unsigned long *depth)
+HBITMAP _dw_load_bitmap(const char *filename, unsigned long *depth)
 {
     void *bitmap = _dw_load_gpbitmap(filename);
     if(bitmap)
@@ -664,7 +664,7 @@
 }
 
 /* Try to load the appropriate image and return the HICON handle */
-HICON _dw_load_icon(char *filename)
+HICON _dw_load_icon(const char *filename)
 {
     void *bitmap = _dw_load_gpbitmap(filename);
     if(bitmap)
@@ -929,7 +929,7 @@
 }
 
 /* Finds the message number for a given signal name */
-ULONG _findsigmessage(char *signame)
+ULONG _findsigmessage(const char *signame)
 {
    int z;
 
@@ -4072,7 +4072,7 @@
    }
 }
 
-void _create_tooltip(HWND handle, char *text)
+void _create_tooltip(HWND handle, const char *text)
 {
     TOOLINFO ti = { 0 };
     
@@ -4352,6 +4352,7 @@
    if (_DW_EDGE_DETECTED = _dw_edge_detect())
    {
 	   wc.lpfnWndProc = (WNDPROC)_edgeWindowProc;
+	   wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    }
    else
 #endif
@@ -4579,7 +4580,7 @@
  *           format: printf style format string.
  *           ...: Additional variables for use in the format.
  */
-void API dw_debug(char *format, ...)
+void API dw_debug(const char *format, ...)
 {
    va_list args;
    char outbuf[1025] = {0}, *thisbuf = outbuf;
@@ -4598,7 +4599,7 @@
  *           format: printf style format string.
  *           ...: Additional variables for use in the format.
  */
-int API dw_messagebox(char *title, int flags, char *format, ...)
+int API dw_messagebox(const char *title, int flags, const char *format, ...)
 {
    va_list args;
    char outbuf[1025] = { 0 }, *thisbuf = outbuf;
@@ -4765,7 +4766,7 @@
    SetParent(handle, newparent);
 }
 
-LOGFONT _get_logfont(HDC hdc, char *fontname)
+LOGFONT _get_logfont(HDC hdc, const char *fontname)
 {
    char  *Italic, *Bold, *myFontName = strchr(fontname, '.');
    int size = atoi(fontname);
@@ -4813,7 +4814,7 @@
 /* Create a font handle from specified font name..
  * or return a handle to the default font.
  */
-HFONT _acquire_font2(HDC hdc, char *fontname)
+HFONT _acquire_font2(HDC hdc, const char *fontname)
 {
    HFONT hfont = 0;
 
@@ -4832,7 +4833,7 @@
 /* Create a font handle from specified font name..
  * or return a handle to the default font.
  */
-HFONT _acquire_font(HWND handle, char *fontname)
+HFONT _acquire_font(HWND handle, const char *fontname)
 {
    HDC hdc = GetDC(handle);
    HFONT hfont = _acquire_font2(hdc, fontname);
@@ -4845,7 +4846,7 @@
  * Parameters:
  *           fontname: Font name in Dynamic Windows format.
  */
-void API dw_font_set_default(char *fontname)
+void API dw_font_set_default(const char *fontname)
 {
     HFONT oldfont = _DefaultFont;
 
@@ -5187,7 +5188,7 @@
  *          handle: The window (widget) handle.
  *          fontname: Name and size of the font in the form "size.fontname"
  */
-int API dw_window_set_font(HWND handle, char *fontname)
+int API dw_window_set_font(HWND handle, const char *fontname)
 {
     HFONT hfont, oldfont;
     ColorInfo *cinfo;
@@ -5256,7 +5257,7 @@
  * Returns:
  *       A malloced buffer with the selected font or NULL on error.
  */
-char * API dw_font_choose(char *currfont)
+char * API dw_font_choose(const char *currfont)
 {
    CHOOSEFONT cf = { 0 };
    LOGFONT lf = { 0 };
@@ -5457,7 +5458,7 @@
  *       title: The Window title.
  *       flStyle: Style flags, see the DW reference.
  */
-HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
+HWND API dw_window_new(HWND hwndOwner, const char *title, ULONG flStyle)
 {
    HWND hwndframe;
    Box *newbox = calloc(sizeof(Box), 1);
@@ -5630,7 +5631,7 @@
  *       pad: Number of pixels to pad around the box.
  *       title: Text to be displayined in the group outline.
  */
-HWND API dw_groupbox_new(int type, int pad, char *title)
+HWND API dw_groupbox_new(int type, int pad, const char *title)
 {
    Box *newbox = calloc(sizeof(Box), 1);
    HWND hwndframe;
@@ -5717,14 +5718,14 @@
 
 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
 void _dw_html_action(HWND hwnd, int action);
-int _dw_html_raw(HWND hwnd, char *string);
-int _dw_html_url(HWND hwnd, char *url);
-int _dw_html_javascript_run(HWND hwnd, char *script, void *scriptdata);
+int _dw_html_raw(HWND hwnd, const char *string);
+int _dw_html_url(HWND hwnd, const char *url);
+int _dw_html_javascript_run(HWND hwnd, const char *script, void *scriptdata);
 #ifdef BUILD_EDGE
 void _dw_edge_action(HWND hwnd, int action);
-int _dw_edge_raw(HWND hwnd, char *string);
-int _dw_edge_url(HWND hwnd, char *url);
-int _dw_edge_javascript_run(HWND hwnd, char *script, void *scriptdata);
+int _dw_edge_raw(HWND hwnd, const char *string);
+int _dw_edge_url(HWND hwnd, const char *url);
+int _dw_edge_javascript_run(HWND hwnd, const char *script, void *scriptdata);
 #endif
 #endif
 
@@ -5755,7 +5756,7 @@
  * Returns:
  *       DW_ERROR_NONE (0) on success.
  */
-int API dw_html_raw(HWND handle, char *string)
+int API dw_html_raw(HWND handle, const char *string)
 {
 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
 #ifdef BUILD_EDGE
@@ -5777,7 +5778,7 @@
  * Returns:
  *       DW_ERROR_NONE (0) on success.
  */
-int API dw_html_url(HWND handle, char *url)
+int API dw_html_url(HWND handle, const char *url)
 {
 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
 #if BUILD_EDGE
@@ -5800,7 +5801,7 @@
  * Returns:
  *       DW_ERROR_NONE (0) on success.
  */
-int dw_html_javascript_run(HWND handle, char *script, void *scriptdata)
+int dw_html_javascript_run(HWND handle, const char *script, void *scriptdata)
 {
 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
 #if BUILD_EDGE
@@ -6355,7 +6356,7 @@
  *       text: The text to be display by the static text widget.
  *       id: An ID to be used with dw_window_from_id() or 0L.
  */
-HWND API dw_text_new(char *text, ULONG id)
+HWND API dw_text_new(const char *text, ULONG id)
 {
    HWND tmp = CreateWindow(STATICCLASSNAME,
                      UTF8toWide(text),
@@ -6385,7 +6386,7 @@
  *       text: The text to be display by the static text widget.
  *       id: An ID to be used with dw_window_from_id() or 0L.
  */
-HWND API dw_status_text_new(char *text, ULONG id)
+HWND API dw_status_text_new(const char *text, ULONG id)
 {
    HWND tmp = CreateWindow(StatusbarClassName,
                      UTF8toWide(text),
@@ -6471,7 +6472,7 @@
  *       text: The default text to be in the entryfield widget.
  *       id: An ID to be used with dw_window_from_id() or 0L.
  */
-HWND API dw_entryfield_password_new(char *text, ULONG id)
+HWND API dw_entryfield_password_new(const char *text, ULONG id)
 {
    HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
                        EDITCLASSNAME,
@@ -6603,7 +6604,7 @@
 }
 
 /* Internal function to create a toolbar based button */
-HWND _create_toolbar(char *text, ULONG id, HICON icon, HBITMAP hbitmap)
+HWND _create_toolbar(const char *text, ULONG id, HICON icon, HBITMAP hbitmap)
 {
    HWND tmp;
    HIMAGELIST imlist, dimlist;
@@ -6668,7 +6669,7 @@
  *       text: Bubble help text to be displayed.
  *       id: An ID of a bitmap in the resource file.
  */
-HWND API dw_bitmapbutton_new(char *text, ULONG id)
+HWND API dw_bitmapbutton_new(const char *text, ULONG id)
 {
    HWND tmp;
    ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
@@ -6722,7 +6723,7 @@
  *                 DW pick the appropriate file extension.
  *                 (BMP or ICO on OS/2 or Windows, XPM on Unix)
  */
-HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename)
+HWND API dw_bitmapbutton_new_from_file(const char *text, unsigned long id, const char *filename)
 {
    HWND tmp;
    ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
@@ -6790,7 +6791,7 @@
  *            (BMP or ICO on OS/2 or Windows, XPM on Unix)
  *       len: length of str
  */
-HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len)
+HWND API dw_bitmapbutton_new_from_data(const char *text, unsigned long id, const char *data, int len)
 {
    HWND tmp;
    ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
@@ -6880,7 +6881,7 @@
  *       text: The text to be display by the static text widget.
  *       id: An ID to be used with dw_window_from_id() or 0L.
  */
-HWND API dw_spinbutton_new(char *text, ULONG id)
+HWND API dw_spinbutton_new(const char *text, ULONG id)
 {
    HWND buddy = CreateWindowEx(WS_EX_CLIENTEDGE,
                         EDITCLASSNAME,
@@ -7209,7 +7210,7 @@
  *                 Windows and a pixmap on Unix, pass
  *                 NULL if you use the id param)
  */
-void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename)
+void API dw_window_set_bitmap(HWND handle, unsigned long id, const char *filename)
 {
    HBITMAP hbitmap = 0;
    HANDLE icon = 0;
@@ -7242,7 +7243,7 @@
  *                 NULL if you use the id param)
  *       len: length of data
  */
-void API dw_window_set_bitmap_from_data(HWND handle, unsigned long id, char *data, int len)
+void API dw_window_set_bitmap_from_data(HWND handle, unsigned long id, const char *data, int len)
 {
    HBITMAP hbitmap=0;
    HICON icon=0;
@@ -7296,7 +7297,7 @@
  *       handle: Handle to the window.
  *       text: The text associsated with a given window.
  */
-void API dw_window_set_text(HWND handle, char *text)
+void API dw_window_set_text(HWND handle, const char *text)
 {
    Box *thisbox;
    TCHAR tmpbuf[100] = {0}, *wtext = UTF8toWide(text);
@@ -7353,7 +7354,7 @@
  *       handle: Handle to the window (widget).
  *       bubbletext: The text in the floating bubble tooltip.
  */
-void API dw_window_set_tooltip(HWND handle, char *bubbletext)
+void API dw_window_set_tooltip(HWND handle, const char *bubbletext)
 {
     ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
     
@@ -8247,7 +8248,7 @@
  *          pageid: Page ID of the tab to set.
  *          text: Pointer to the text to set.
  */
-void API dw_notebook_page_set_text(HWND handle, ULONG pageidx, char *text)
+void API dw_notebook_page_set_text(HWND handle, ULONG pageidx, const char *text)
 {
 
    NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
@@ -8274,7 +8275,7 @@
  *          pageid: Page ID of the tab to set.
  *          text: Pointer to the text to set.
  */
-void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text)
+void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, const char *text)
 {
 }
 
@@ -8416,7 +8417,7 @@
  *          handle: Handle to the listbox to be appended to.
  *          text: Text to append into listbox.
  */
-void API dw_listbox_append(HWND handle, char *text)
+void API dw_listbox_append(HWND handle, const char *text)
 {
    TCHAR tmpbuf[100] = {0};
 
@@ -8515,7 +8516,7 @@
  *          index: Index into the list to be queried.
  *          buffer: Buffer where text will be copied.
  */
-void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
+void API dw_listbox_set_text(HWND handle, unsigned int index, const char *buffer)
 {
    TCHAR tmpbuf[100] = {0};
 
@@ -9194,7 +9195,7 @@
  *          parent: Parent handle or 0 if root.
  *          itemdata: Item specific data.
  */
-HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata)
+HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
 {
    TVITEM tvi;
    TVINSERTSTRUCT tvins;
@@ -9224,7 +9225,7 @@
  *          parent: Parent handle or 0 if root.
  *          itemdata: Item specific data.
  */
-HTREEITEM API dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata)
+HTREEITEM API dw_tree_insert(HWND handle, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
 {
    TVITEM tvi;
    TVINSERTSTRUCT tvins;
@@ -9253,7 +9254,7 @@
  *          title: The text title of the entry.
  *          icon: Handle to coresponding icon.
  */
-void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon)
+void API dw_tree_item_change(HWND handle, HTREEITEM item, const char *title, HICN icon)
 {
    TVITEM tvi;
 
@@ -9455,7 +9456,7 @@
  *          handle: Handle to the container to be configured.
  *          title: The title to be displayed in the main column.
  */
-void API dw_filesystem_set_column_title(HWND handle, char *title)
+void API dw_filesystem_set_column_title(HWND handle, const char *title)
 {
     char *newtitle = _strdup(title ? title : "");
 
@@ -9514,7 +9515,7 @@
  *                 DW pick the appropriate file extension.
  *                 (ICO on OS/2 or Windows, XPM on Unix)
  */
-HICN API dw_icon_load_from_file(char *filename)
+HICN API dw_icon_load_from_file(const char *filename)
 {
 #ifdef GDIPLUS
     return _dw_load_icon(filename);
@@ -9551,7 +9552,7 @@
  *                 DW pick the appropriate file extension.
  *                 (ICO on OS/2 or Windows, XPM on Unix)
  */
-HICN API dw_icon_load_from_data(char *data, int len)
+HICN API dw_icon_load_from_data(const char *data, int len)
 {
    HANDLE icon = 0;
    char *file;
@@ -9689,7 +9690,7 @@
  *          row: Zero based row of data being set.
  *          data: Pointer to the data to be added.
  */
-void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon)
+void API dw_filesystem_set_file(HWND handle, void *pointer, int row, const char *filename, HICN icon)
 {
    LV_ITEM lvi;
    int item = 0;
@@ -9860,7 +9861,7 @@
  *          row: Zero based row of data being set.
  *          data: Pointer to the data to be added.
  */
-void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon)
+void API dw_filesystem_change_file(HWND handle, int row, const char *filename, HICN icon)
 {
    dw_filesystem_set_file(handle, NULL, row, filename, icon);
 }
@@ -9997,9 +9998,9 @@
  *          row: Zero based row of data being set.
  *          title: String title of the item.
  */
-void API dw_container_set_row_title(void *pointer, int row, char *title)
-{
-   _dw_container_set_row_data(pointer, pointer, row, _DW_DATA_TYPE_STRING, title);
+void API dw_container_set_row_title(void *pointer, int row, const char *title)
+{
+   _dw_container_set_row_data(pointer, pointer, row, _DW_DATA_TYPE_STRING, (void *)title);
 }
 
 /*
@@ -10009,9 +10010,9 @@
  *          row: Zero based row of data being set.
  *          title: String title of the item.
  */
-void API dw_container_change_row_title(HWND handle, int row, char *title)
-{
-   _dw_container_set_row_data(handle, NULL, row, _DW_DATA_TYPE_STRING, title);
+void API dw_container_change_row_title(HWND handle, int row, const char *title)
+{
+   _dw_container_set_row_data(handle, NULL, row, _DW_DATA_TYPE_STRING, (void *)title);
 }
 
 /*
@@ -10194,7 +10195,7 @@
  *       handle: Handle to the window (widget) to be queried.
  *       text:  Text usually returned by dw_container_query().
  */
-void API dw_container_cursor(HWND handle, char *text)
+void API dw_container_cursor(HWND handle, const char *text)
 {
    int index = ListView_GetNextItem(handle, -1, LVNI_ALL);
 
@@ -10272,7 +10273,7 @@
  *       handle: Handle to the window (widget).
  *       text:  Text usually returned by dw_container_query().
  */
-void API dw_container_delete_row(HWND handle, char *text)
+void API dw_container_delete_row(HWND handle, const char *text)
 {
    int index = ListView_GetNextItem(handle, -1, LVNI_ALL);
 
@@ -10424,7 +10425,7 @@
  *       icon: Icon handle to display in the taskbar.
  *       bubbletext: Text to show when the mouse is above the icon.
  */
-void API dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext)
+void API dw_taskbar_insert(HWND handle, HICN icon, const char *bubbletext)
 {
    NOTIFYICONDATA tnid;
 
@@ -10435,7 +10436,7 @@
    tnid.uCallbackMessage = WM_USER+2;
    tnid.hIcon = (HICON)icon;
    if(bubbletext)
-      _tcsncpy(tnid.szTip, UTF8toWide(bubbletext), sizeof(tnid.szTip));
+      _tcsncpy(tnid.szTip, UTF8toWide(bubbletext), sizeof(tnid.szTip) / sizeof(TCHAR));
    else
       tnid.szTip[0] = 0;
 
@@ -10951,7 +10952,7 @@
  *       y: Y coordinate.
  *       text: Text to be displayed.
  */
-void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
+void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, const char *text)
 {
    HDC hdc;
    int mustdelete = 0;
@@ -11011,7 +11012,7 @@
  *       width: Pointer to a variable to be filled in with the width.
  *       height Pointer to a variable to be filled in with the height.
  */
-void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height)
+void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, const char *text, int *width, int *height)
 {
    HDC hdc;
    int mustdelete = 0;
@@ -11168,7 +11169,7 @@
  * Returns:
  *       A handle to a pixmap or NULL on failure.
  */
-HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename)
+HPIXMAP API dw_pixmap_new_from_file(HWND handle, const char *filename)
 {
    HPIXMAP pixmap;
    BITMAP bm;
@@ -11233,7 +11234,7 @@
  * Returns:
  *       A handle to a pixmap or NULL on failure.
  */
-HPIXMAP API dw_pixmap_new_from_data(HWND handle, char *data, int len)
+HPIXMAP API dw_pixmap_new_from_data(HWND handle, const char *data, int len)
 {
    HPIXMAP pixmap;
    BITMAP bm;
@@ -11354,7 +11355,7 @@
  * Returns:
  *       DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
  */
-int API dw_pixmap_set_font(HPIXMAP pixmap, char *fontname)
+int API dw_pixmap_set_font(HPIXMAP pixmap, const char *fontname)
 {
     if(pixmap)
     {
@@ -11545,7 +11546,7 @@
  *         func: A pointer to a function pointer, to obtain
  *               the address.
  */
-int API dw_module_symbol(HMOD handle, char *name, void**func)
+int API dw_module_symbol(HMOD handle, const char *name, void**func)
 {
    if(!func || !name)
       return DW_ERROR_UNKNOWN;
@@ -11701,7 +11702,7 @@
  *         name: Name given to semaphore which can be opened
  *               by other processes.
  */
-HEV API dw_named_event_new(char *name)
+HEV API dw_named_event_new(const char *name)
 {
    SECURITY_ATTRIBUTES sa;
 
@@ -11717,7 +11718,7 @@
  *         eve: Handle to the semaphore obtained by
  *              a create call.
  */
-HEV API dw_named_event_get(char *name)
+HEV API dw_named_event_get(const char *name)
 {
    return OpenEvent(EVENT_ALL_ACCESS, FALSE, UTF8toWide(name));
 }
@@ -11791,7 +11792,7 @@
  *         size: Size in bytes of the shared memory region to allocate.
  *         name: A string pointer to a unique memory name.
  */
-HSHM API dw_named_memory_new(void **dest, int size, char *name)
+HSHM API dw_named_memory_new(void **dest, int size, const char *name)
 {
    SECURITY_ATTRIBUTES sa;
    HSHM handle;
@@ -11823,7 +11824,7 @@
  *         size: Size in bytes of the shared memory region to requested.
  *         name: A string pointer to a unique memory name.
  */
-HSHM API dw_named_memory_get(void **dest, int size, char *name)
+HSHM API dw_named_memory_get(void **dest, int size, const char *name)
 {
    HSHM handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, UTF8toWide(name));
 
@@ -12249,7 +12250,7 @@
  * Parameters:
  *       Text.
  */
-void API dw_clipboard_set_text( char *str, int len )
+void API dw_clipboard_set_text(const char *str, int len)
 {
    HGLOBAL ptr1;
    LPTSTR ptr2;
@@ -12373,7 +12374,7 @@
  *       the file path on success.
  *
  */
-char * API dw_file_browse(char *title, char *defpath, char *ext, int flags)
+char * API dw_file_browse(const char *title, const char *defpath, char *ext, int flags)
 {
    OPENFILENAME of = {0};
    TCHAR filenamebuf[BROWSEBUFSIZE+1] = {0}, *fbuf = filenamebuf;
@@ -12494,7 +12495,7 @@
  * Returns:
  *       -1 on error.
  */
-int API dw_exec(char *program, int type, char **params)
+int API dw_exec(const char *program, int type, char **params)
 {
    char **newparams;
    int retcode, count = 0, z;
@@ -12743,7 +12744,7 @@
  * a given window handle.  Used in dw_window_set_data() and
  * dw_window_get_data().
  */
-UserData *_find_userdata(UserData **root, char *varname)
+UserData *_find_userdata(UserData **root, const char *varname)
 {
    UserData *tmp = *root;
 
@@ -12756,7 +12757,7 @@
    return NULL;
 }
 
-int _new_userdata(UserData **root, char *varname, void *data)
+int _new_userdata(UserData **root, const char *varname, void *data)
 {
    UserData *new = _find_userdata(root, varname);
 
@@ -12794,7 +12795,7 @@
    return FALSE;
 }
 
-int _remove_userdata(UserData **root, char *varname, int all)
+int _remove_userdata(UserData **root, const char *varname, int all)
 {
    UserData *prev = NULL, *tmp = *root;
 
@@ -12838,7 +12839,7 @@
  *       dataname: A string pointer identifying which signal to be hooked.
  *       data: User data to be passed to the handler function.
  */
-void API dw_window_set_data(HWND window, char *dataname, void *data)
+void API dw_window_set_data(HWND window, const char *dataname, void *data)
 {
    ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
 
@@ -12873,7 +12874,7 @@
  *       dataname: A string pointer identifying which signal to be hooked.
  *       data: User data to be passed to the handler function.
  */
-void * API dw_window_get_data(HWND window, char *dataname)
+void * API dw_window_get_data(HWND window, const char *dataname)
 {
    ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
 
@@ -12961,7 +12962,7 @@
  *       sigfunc: The pointer to the function to be used as the callback.
  *       data: User data to be passed to the handler function.
  */
-void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
+void API dw_signal_connect(HWND window, const char *signame, void *sigfunc, void *data)
 {
     dw_signal_connect_data(window, signame, sigfunc, NULL, data);
 }
@@ -12975,7 +12976,7 @@
  *       discfunc: The pointer to the function called when this handler is removed.
  *       data: User data to be passed to the handler function.
  */
-void API dw_signal_connect_data(HWND window, char *signame, void *sigfunc, void *discfunc, void *data)
+void API dw_signal_connect_data(HWND window, const char *signame, void *sigfunc, void *discfunc, void *data)
 {
    ULONG message = 0, id = 0;
 
@@ -13014,7 +13015,7 @@
  * Parameters:
  *       window: Window handle of callback to be removed.
  */
-void API dw_signal_disconnect_by_name(HWND window, char *signame)
+void API dw_signal_disconnect_by_name(HWND window, const char *signame)
 {
    SignalHandler *prev = NULL, *tmp = Root;
    ULONG message;
@@ -13145,7 +13146,7 @@
  *       Wide string that needs to be freed with dw_free()
  *       or NULL on failure.
  */
-wchar_t * API dw_utf8_to_wchar(char *utf8string)
+wchar_t * API dw_utf8_to_wchar(const char *utf8string)
 {
  #ifdef UNICODE
     return _myUTF8toWide(utf8string, malloc(MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR)));
@@ -13162,7 +13163,7 @@
  *       UTF-8 encoded string that needs to be freed with dw_free()
  *       or NULL on failure.
  */
-char * API dw_wchar_to_utf8(wchar_t *wstring)
+char * API dw_wchar_to_utf8(const wchar_t *wstring)
 {
 #ifdef UNICODE
     return _myWideToUTF8(wstring, malloc(WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL)));
--- a/win/edge.cpp	Sat Nov 16 09:43:17 2019 +0000
+++ b/win/edge.cpp	Sun Nov 17 03:13:37 2019 +0000
@@ -15,15 +15,16 @@
 
 using namespace Microsoft::WRL;
 
-#define _DW_HTML_DATA_NAME (char *)"_dw_edge"
-#define _DW_HTML_DATA_LOCATION (char *)"_dw_edge_location"
-#define _DW_HTML_DATA_RAW (char *)"_dw_edge_raw"
+#define _DW_HTML_DATA_NAME "_dw_edge"
+#define _DW_HTML_DATA_ENV "_dw_edge_env"
+#define _DW_HTML_DATA_LOCATION "_dw_edge_location"
+#define _DW_HTML_DATA_RAW "_dw_edge_raw"
 
 extern "C" {
 
 	/* Import the character conversion functions from dw.c */
-	LPWSTR _myUTF8toWide(char *utf8string, void *outbuf);
-	char *_myWideToUTF8(LPWSTR widestring, void *outbuf);
+	LPWSTR _myUTF8toWide(const char *utf8string, void *outbuf);
+	char *_myWideToUTF8(LPCWSTR widestring, void *outbuf);
 	#define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL)
 	#define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL)
 	LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2);
@@ -135,7 +136,7 @@
 	 * RETURNS: 0 if success, or non-zero if an error.
 	 */
 
-	int _dw_edge_raw(HWND hwnd, char *string)
+	int _dw_edge_raw(HWND hwnd, const char *string)
 	{
 		IWebView2WebView* webview;
 
@@ -159,7 +160,7 @@
 	 * RETURNS: 0 if success, or non-zero if an error.
 	 */
 
-	int _dw_edge_url(HWND hwnd, char *url)
+	int _dw_edge_url(HWND hwnd, const char *url)
 	{
 		IWebView2WebView* webview;
 
@@ -184,7 +185,7 @@
 	 * RETURNS: 0 if success, or non-zero if an error.
 	 */
 
-	int _dw_edge_javascript_run(HWND hwnd, char *script, void *scriptdata)
+	int _dw_edge_javascript_run(HWND hwnd, const char *script, void *scriptdata)
 	{
 		IWebView2WebView* webview;
 
@@ -230,6 +231,14 @@
 			return(0);
 		}
 
+		case WM_PAINT:
+		{
+			PAINTSTRUCT ps;
+			HDC hdc = BeginPaint(hWnd, &ps);
+			EndPaint(hWnd, &ps);
+			return(0);
+		}
+
 		case WM_CREATE:
 		{
 			// Step 3 - Create a single WebView within the parent window
@@ -238,6 +247,9 @@
 				Callback<IWebView2CreateWebView2EnvironmentCompletedHandler>(
 					[hWnd](HRESULT result, IWebView2Environment* env) -> HRESULT {
 
+						// Save the environment for later use
+						dw_window_set_data(hWnd, _DW_HTML_DATA_ENV, DW_POINTER(env));
+
 						// Create a WebView, whose parent is the main window hWnd
 						env->CreateWebView(hWnd, Callback<IWebView2CreateWebViewCompletedHandler>(
 							[hWnd](HRESULT result, IWebView2WebView* webview) -> HRESULT {
@@ -263,10 +275,6 @@
 								EventRegistrationToken token;
 
 								// Register a handler for the NavigationStarting event.
-								// This handler will check the domain being navigated to, and if the domain
-								// matches a list of blocked sites, it will cancel the navigation and
-								// possibly display a warning page.  It will also disable JavaScript on
-								// selected websites.
 								webview->add_NavigationStarting(
 									Callback<IWebView2NavigationStartingEventHandler>(
 										[hWnd](IWebView2WebView* sender,
@@ -282,8 +290,6 @@
 										}).Get(), &token);
 
 								// Register a handler for the DocumentStateChanged event.
-								// This handler will read the webview's source URI and update
-								// the app's address bar.
 								webview->add_DocumentStateChanged(
 									Callback<IWebView2DocumentStateChangedEventHandler>(
 										[hWnd](IWebView2WebView* sender,
@@ -299,7 +305,6 @@
 										}).Get(), &token);
 
 								// Register a handler for the NavigationCompleted event.
-								// If the navigation was successful, update the back and forward buttons.
 								webview->add_NavigationCompleted(
 									Callback<IWebView2NavigationCompletedEventHandler>(
 										[hWnd](IWebView2WebView* sender,